Boxplot Schmoxplot: How to Plot Means and Standard Errors Conditioned by a Factor in R

Plot mean, standard deviation, standard error of the mean, and confidence interval

names=data$method
x = 1:13*2-1
CI.up = as.numeric(data$mean)+as.numeric(data$ci)
CI.dn = as.numeric(data$mean)-as.numeric(data$ci)
plot(data$mean~x, cex=1.5,xaxt='n',ylim=c(0.3,0.40), xlab='',ylab='lalala!', main='blahblahblah',col='blue',pch=16)
axis(1, at=x, labels=names)
arrows(x,CI.dn,x,CI.up,code=3,length=0.2,angle=90,col='red')
legend("bottomleft",paste(names,": S.E=",data$se),ncol=6,text.width=1)

output

output

Boxplot overlaid on dot plot + means, means in wrong position

The help for ?position_dodge just says that dodging things with different widths is tricky - I usually tweak this manually. Trying a few values, it looks like you want the points to take a dodge width that is 3/4 of the boxplot width but I don't know why or if that holds for other geoms. I would try changing the width for the stat_summary call to 0.15



Related Topics



Leave a reply



Submit