To get ggplot
to plot minor breaks correctly on a logarithmic scale, I had to do this thing:
faceplant1 <- function(x) {
return (c(x[1]*10^.25, x[2]/10^.25))
}
faceplant2 <- function(x) {
return (rep(seq(1,9),5)*rep(10^seq(-6,-2), each=9))
}
ggplot(mydata, aes(x=myseries)) +
geom_density() +
scale_x_log10(limits=c(1e-6, 1e-1),
breaks=10^seq(-6,-1),
minor_breaks=trans_breaks(faceplant1, faceplant2, n=45))
Is there a simpler way to achieve this?
The end result should look like: