
Untitled
By: a guest on
Jul 29th, 2012 | syntax:
None | size: 0.80 KB | hits: 13 | expires: Never
Is it possible to change the ylim and xlim when the plot has already been drawn?
> plot(c(1,2,3,4,5), ylim=c(0,10))
> points(c(5,6,7,8,9))
> plot(c(1,2,3,4,5))
> points(c(5,6,7,8,9), ylim=c(0,10))
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))
g=ggplot(data=df,aes(x=age,y=veg))
g=g+stat_summary(fun.y=mean,geom="point")
g
a<-g+coord_cartesian(xlim=c(0,100))
a+geom_point(data=df,aes(x=extra,y=veg))
require(ggplot2)
data(mpg)
g = ggplot(mpg, aes(cyl, cty)) + geom_point() + xlim(5, 8)
g
g + xlim(4,8)
my.data <- seq(0,5)
my.points <- seq(5,9)
plot(my.data, ylim=c(0,max(my.data,my.points)))
points(my.points)
my.data <- seq(0,5)
my.points <- seq(5,9)
plot(my.data, ylim=c(min(my.data,my.points),max(my.data,my.points)))
points(my.points)