[R] ggplot2 - expand range?
Pedro de Barros
pbarros at ualg.pt
Thu Nov 1 08:38:32 CET 2007
Dear UserRs,
I am trying to use systematically ggplot2 for most of my plots, but I
am fighting some lack of documentation, which I try to overcome.
I want to build a scatterplot where the axes cross exactly at (0,0).
I tried using scale_y_continuous(limits=c(0,10)), but I always get an
extra space at the bottom of the axes. The code I used is below.
> plotdata<-data.frame(x=1:10, y=runif(10))
> plot<-ggplot()
> plot<-plot+layer(data=plotdata, mapping=aes_string(x='x',y='y'),
geom='point', stat='identity', size=4)
> plot<-plot+ scale_y_continuous(limits=c(0,1))
> print(plot)
I believe there may be a way to use expand_range to fix this (I think
I read about it somewhere), but I do not seem to find out how.
I have searched the ggplot help and
the archives, but cannot find the answer to this issue.
I would really appreciate if anyone could give me a pointer.
I am using R2.6.0 (patched) on Windows
Thanks,
Pedro
More information about the R-help
mailing list