[R] dotplots with error bars

Jim Lemon jim at bitwrit.com.au
Mon Feb 13 10:31:17 CET 2012

On 02/13/2012 09:51 AM, Colin Wahl wrote:
> Does anyone have any recommendations for producing dotplots with error
> bars? Are there packages available for this? I searched far and wide
> and cannot find a suitable option.
> I am trying to produce publication-quality figures for my thesis
> results. Dotplots (Cleveland dotplots) are a much better form of
> summarizing barchart-type data. It does not appear that any of the
> main plotting packages in r support dotplots with error bars.
> Considering the benefit of these plots, I find it difficult to believe
> that they have not been fully integrated into R.
> I did find a function "dotplots.errors" available here:
> http://agrobiol.sggw.waw.pl/~cbcs/articles/CBCS_5_2_2.pdf.
> However, I have found this function absurdly difficult to use when
> customizing figures (ordering displays properly, or just simple
> getting the function to work.)
> I've been struggling for the last few hours to figure out the error:
> "error using packet 1 sum not meaningful for factors." Unlike other
> packages, this function doesnt have a ?dotplots.errors to help guide
> troubleshooting. I presume this is a technicality due to the a numeric
> variable being identified as a factor. However, I've double checked
> that all the numeric columns in the data frame are not factors, and
> the error persists.
> I'd really prefer not just calling it quits and resorting to
> old-school sloppy bar charts, but if thats what I need to do to finish
> this in a timely manner, then so be it.
Hi Colin,
I am grateful that Marcin Kozak gave plotrix a plug in the paper, and to 
show my gratitude, I'll explain how to use centipede.plot to get the 
illustration in the paper. Assume that you have the data frame shown on 
p70 of the paper:


Now, to echo Marcin, let us produce the plot:

  right.labels=rep("",13),xlab="Mean plant height (cm) +- SE")

If you want the mean value line:


The grid lines are a bit more difficult. You could insert a line into 
the function just after the call to box() to draw grid lines under each dot:


However, this looks like such a good idea that I will add two arguments 
to the function to do the vertical line(s) and horizontal grid 
automatically, and this option will appear in the next version of plotrix.


More information about the R-help mailing list