scale & breaks & minor_breaks

410 views
Skip to first unread message

John Owens

unread,
Apr 30, 2010, 11:54:04 AM4/30/10
to ggplot2
I'd like to wrangle scale_y_log10 into putting major and minor lines
where I want them. (The current graph I'm drawing puts 2 major lines
and 2 minor lines per decade by default. I'd like instead 1 major line
per decade, at 10^x, and 9 minor lines.)

What is working is if I call (I'm using rpy2, so the syntax might be
off as I'm translating to R):

scale_y_log10(breaks="10**(0:10)",
minor_breaks=([1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]))
+ \

but then I'm just putting them in manually.

I'd much rather be able to say "draw one break every decade and 9
evenly spaced minor breaks every decade" rather than have to type them
in manually. Any way to do this?

JDO

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

fernando

unread,
Apr 30, 2010, 6:43:07 PM4/30/10
to John Owens, ggplot2
Don't know if you are looking to something like this (also note my absolute
ignorance on rpy2), but hope this helps

library(ggplot2)
df <- data.frame(x = c(2:6), y = 10^c(2:6))
mbreaks_y <- round(range(log10(df$y)))
qplot(x, y, data = df) +
scale_y_log10(breaks = 10^c(mbreaks_y[1]:mbreaks_y[2]),
minor_breaks = rep(10^c(mbreaks_y[1]: (mbreaks_y[2] - 1) ),
each = 9) *
rep(1:9, mbreaks_y[2] - mbreaks_y[1]))


-----Mensaje original-----
De: ggp...@googlegroups.com [mailto:ggp...@googlegroups.com] En nombre de
John Owens
Enviado el: viernes, 30 de abril de 2010 17:54
Para: ggplot2
Asunto: scale & breaks & minor_breaks

John Owens

unread,
May 1, 2010, 7:59:26 PM5/1/10
to ggplot2
Thanks Fernando - that worked great. Much appreciated!

JDO

On Apr 30, 3:43 pm, "fernando" <fgtabo...@gmail.com> wrote:
> Don't know if you are looking to something like this (also note my absolute
> ignorance on rpy2), but hope this helps

Reply all
Reply to author
Forward
0 new messages