[R] ggplot and xlim/ylim

hadley wickham h.wickham at gmail.com
Thu Sep 20 15:59:46 CEST 2007


Hi Jiho,

To figure this out, you need to think about exactly what you are doing
when you change the limits - what part of the plot are you changing?
You are changing the scales, and if you have a look at
http://had.co.nz/ggplot2/scale_continuous.html, you'll see you need
something like:

+ scale_y_continuous(limits=c(0,10)

Remember, you can also modify qplot in the same way as ggplot:

qplot(...) + geom_point() + ...

Regards,

Hadley

On 9/20/07, jiho <jo.irisson at gmail.com> wrote:
> Hello everyone,
>
> I am (happily) using ggplot2 for all my plotting now and I wondered
> is there is an easy way to specify xlim and ylim somewhere when using
> the ggplot syntax, as opposed to the qplot syntax. Eg.
>
>   qplot(data=mtcars,y=wt, x=qsec,xlim=c(0,30))
>
> <->
>
> ggplot(mtcars, aes(y=wt, x=qsec)) + geom_point() + ???
>
> Indeed the ggplot syntax is in general more flexible and powerful and
> I usually rely on it in scripts. It would be nice to know how to use
> xlim/ylim with this syntax.
>
> Thank you in advance.
>
> JiHO
> ---
> http://jo.irisson.free.fr/
>
> ______________________________________________
> 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