Re: [R] adding the mean and standard deviation to boxplots

From: Felipe Carrillo <>
Date: Tue, 5 Feb 2008 10:58:40 -0800 (PST)

You can do this with ggplot2. The code below puts 95% CI,a smooth line and the mean(blue point)on the same plot.

  r <- ggplot(ToothGrowth, aes(y=len, x=factor(dose)))   r$background.fill = "cornsilk"
r + geom_boxplot(aes(colour=supp)) +
stat_summary(aes(group=supp),fun="mean_cl_normal",colour="red",geom="smooth",linetype=3,size=1) +   


   grid.gedit("label", gp=gpar(fontsize=10, col="red")) # color the axis labels

Felipe D. Carrillo
  Fishery Biologist
  US Fish & Wildlife Service
  California, USA

Be a better friend, newshound, and mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 05 Feb 2008 - 19:00:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 05 Feb 2008 - 19:30:14 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive