Ggplot2 - grids seem to fail with very small numbers on a scale

I make a bunch of boxes in ggplot2 of very small numbers on a log10 scale. There seems to be some threshold where ggplot2 stops displaying the grid correctly. A plot using dat1 has missing grid lines, and dat2 works as I would like. The difference between the two just seems to be a range problem.

library(ggplot2) set.seed(1234) dat1 = data.frame( val = c(10^(runif(90,-12,-10)), 10^(runif(10,-15,-12)), 10^(runif(94,-12, -9)), 10^(runif(6, -14,-12))), d = c(rep(1,100),rep(2,100)) ) dat2 = data.frame( val = c(10^(runif(90,-9,-7)), 10^(runif(10,-11,-9)), 10^(runif(94,-9,-6)), 10^(runif(6, -10,-9))), d = c(rep(1,100),rep(2,100)) ) p = ggplot(dat1, aes(factor(d), val)) print(p + geom_boxplot() + scale_y_log10()) p = ggplot(dat2, aes(factor(d), val)) print(p + geom_boxplot() + scale_y_log10()) 

Does anyone have any advice? Is this a numerical issue with logging? All values ​​must be greater than .Machine$double.eps

where are the gridlines!found the gridlines!

+4
source share

All Articles