# Untitled

By: a guest on Jul 29th, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 13  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. Is it possible to change the ylim and xlim when the plot has already been drawn?
2. > plot(c(1,2,3,4,5), ylim=c(0,10))
3. > points(c(5,6,7,8,9))
4.
5. > plot(c(1,2,3,4,5))
6. > points(c(5,6,7,8,9), ylim=c(0,10))
7.
8. df <-data.frame(age=c(10,10,20,20,25,25,25),veg=c(0,1,0,1,1,0,1),extra=c(10,10,20,20,25,25,90))
9.  g=ggplot(data=df,aes(x=age,y=veg))
10.  g=g+stat_summary(fun.y=mean,geom="point")
11.  g
12.
13. a<-g+coord_cartesian(xlim=c(0,100))
14. a+geom_point(data=df,aes(x=extra,y=veg))
15.
16. require(ggplot2)
17. data(mpg)
18.
19. g = ggplot(mpg, aes(cyl, cty)) + geom_point() + xlim(5, 8)
20. g
21. g + xlim(4,8)
22.
23. my.data <- seq(0,5)
24. my.points <- seq(5,9)
25. plot(my.data, ylim=c(0,max(my.data,my.points)))
26. points(my.points)
27.
28. my.data <- seq(0,5)
29. my.points <- seq(5,9)
30. plot(my.data, ylim=c(min(my.data,my.points),max(my.data,my.points)))
31. points(my.points)