[R] reversing the scale on ggplot

hadley wickham h.wickham at gmail.com
Thu Jan 3 02:51:32 CET 2008


Hi Pedro,

Sorry for missing this email - the good news is that in the next
version of ggplot (hopefully coming out in the next few days), you'll
be able to do:

qplot(x, y, data=plotdata) + scale_x_reverse()
qplot(x, y, data=plotdata) + scale_y_reverse()

to get reversed scales

Hadley

On Oct 31, 2007 4:56 AM, Pedro de Barros <pbarros at ualg.pt> wrote:
> Dear All,
>
>
> I am trying to build a simple ggplot, but where the scale is
> reversed, i.e. the largest numbers are on the bottom.
> An example of the code I am using is
>
>  > 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(1,0))
>  > print(plot)
> I was hoping that by reversing the limits argument I would obtain the
> result I wanted, but to no avail. 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
http://had.co.nz/




More information about the R-help mailing list