How to set minor grid line breaks to log2 cycles

18 views
Skip to first unread message

Hefin Rhys

unread,
Dec 14, 2016, 11:41:09 AM12/14/16
to ggplot2
Hi all, say I construct a plot using the following:

library(ggplot2)

myData
<- data.frame("xVar" = c(1, 2, 4, 8, 16, 32, 64, 128, 256),
                     
"yVar" = 1:9)

ggplot
(data = myData, aes(x = xVar, y = yVar)) +
  geom_line
() +
  scale_x_continuous
(trans = "log2")

I have intentionally plotted the original values on a log2-transformed x axis, rather than transform the values themselves so as to preserve some interpretability of the values. To make it more immediately obvious that the x axis is transformed, I would like to set the minor grid line breaks to show the cycles of each decade, as shown here: https://msu.edu/course/fsc/441/6cycle.gif

Is there a way of doing this for both this log2 transformation, and for log10 transformations also?

Many thanks
Hefin

Hadley Wickham

unread,
Dec 30, 2016, 4:59:43 PM12/30/16
to Hefin Rhys, ggplot2
Trying supplying the minor_breaks parameter.

Hadley
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
http://hadley.nz
Reply all
Reply to author
Forward
0 new messages