possible to set limits in log scale?

638 views
Skip to first unread message

Gene Leynes

unread,
Sep 19, 2012, 9:49:11 PM9/19/12
to ggp...@googlegroups.com
xx=1:10
yy=rnorm(10,100,30)
dd = data.frame(xx,yy)
ggplot(dd, aes(x = xx, y = yy)) + geom_line()+ scale_y_continuous(limits=c(50,150))
## Something like this?
ggplot(dd, aes(x = xx, y = yy)) + geom_line()+ scale_y_log10(limits=c(-3,3))

Winston Chang

unread,
Sep 19, 2012, 10:57:22 PM9/19/12
to Gene Leynes, ggp...@googlegroups.com
You're probably looking to do something like this:
ggplot(dd, aes(x = xx, y = yy)) + geom_line()+
scale_y_log10(limits=c(.001, 1000))

-Winston
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Gene Leynes

unread,
Sep 20, 2012, 2:02:19 PM9/20/12
to ggp...@googlegroups.com, Gene Leynes
Yes, thanks.  

I guess that you can't specify log scale that crosses 0 or negative.  In my real example I was trying to include 0, and that was the problem.  I guess that makes sense, and it's consistent with the base package.
Reply all
Reply to author
Forward
0 new messages