I am hoping to set up a box and whisker plot with log(ORs). On a linear scale, I am able to specify my breaks/ticks at 0.5, 1, 2, 4, but when I log-transform my y-axis, tick marks only appear at 1 and 2. I know I am missing something trivial, and am open to the fact that I am missing something very simple. I've tried looking through about 20 StackOverflow pages including someone who described a similar problem for javascript. Any help wuould be appreciated!
This will yield a linear plot with the breaks I want (but not log transformed)
plot <- ggplot(data=df,
aes(x = group, y = riskratio))+
geom_point(shape=22, fill="black", size=5)+
scale_y_continuous(trans = 'log10', breaks = c(0.5, 1, 2) )+
geom_hline(aes(fill=group),yintercept =1, linetype=2)+
xlab('score\n(quintiles)')+ ylab("Multivariable odds ratio\n(95% confidence interval) \n")+
geom_errorbar(aes(ymin=lowerlimit, ymax=upperlimit,col=group),width=0.2,cex=1, color = 'gray50')+
facet_wrap(~condition,strip.position="top",nrow=1,scales = "free_x") +
guides(color = "none") +
geom_smooth(alpha=0.3, method = "lm", se=TRUE, aes(group=1), color='gray50', linetype=0) +
theme_bw(base_size = 24) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
annotate(geom = "text", label = c('p-trend=0.003', 'p-trend=0.004', 'p-trend=0.27'), size = 7, hjust = .1, x='Q1 (ref.)', y =2.3)
plot(plot)
This will yield a log transformed plot but without the breaks I want (just 1 and 2)
plot <- ggplot(data=df,
aes(x = group, y = riskratio))+
geom_point(shape=22, fill="black", size=5)+
scale_y_continuous(trans = 'log10', breaks = c(0.5, 1, 2) )+
geom_hline(aes(fill=group),yintercept =1, linetype=2)+
xlab('score\n(quintiles)')+ ylab("Multivariable odds ratio\n(95% confidence interval) \n")+
geom_errorbar(aes(ymin=lowerlimit, ymax=upperlimit,col=group),width=0.2,cex=1, color = 'gray50')+
facet_wrap(~condition,strip.position="top",nrow=1,scales = "free_x") +
guides(color = "none") +
geom_smooth(alpha=0.3, method = "lm", se=TRUE, aes(group=1), color='gray50', linetype=0) +
theme_bw(base_size = 24) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
annotate(geom = "text", label = c('p-trend=0.003', 'p-trend=0.004', 'p-trend=0.27'), size = 7, hjust = .1, x='Q1 (ref.)', y =2.3)
plot(plot)