# [R] Error bars on barplots

Martin Maechler maechler at stat.math.ethz.ch
Tue Sep 14 17:17:30 CEST 1999

```>>>>> On Tue, 7 Sep 1999 12:24:38 GMT+2, "Karen KOTSCHY" <karen at gecko.biol.wits.ac.za> said:

Karen> Hi everyone I've finally had a chance to look at this problem
Karen> again. Thanks to Paul Murrell and Bendix Carstensen, putting
Karen> error bars on barplots with single bars is quite simple, as
Karen> barplot returns the x locations of the bar midpoints.

Karen> However... with plots where you have groups of bars (where x is
Karen> a matrix and beside=T), it is not as simple. One can work out
Karen> the x locations of each individual bar manually, knowing the bar
Karen> width and the midpoint of the group. I've written a function to
Karen> do this when there are 3 bars in a group (see below). I'm sure
Karen> the R gurus out there could suggest a more elegant or a simpler
Karen> way!

<....>

Karen> ----------------------------
Karen> Karen Kotschy Centre for Water in the Environment University of
Karen> the Witwatersrand Johannesburg

I've changed  barplot() to
- accept a "plot = FALSE" argument (default remains TRUE)
- in the above case ``beside = TRUE'' return
a vector of locations for *each* bar
(instead of midpoints of group of "beside-bar"s)

I wonder if we shouldn't even return a matrix of these locations
with the same dimension as  the barplot matrix argument.
This matrix result could still be addressed as a vector (as all
matrices can), but additionally, one could also use  apply(<res>, 2, mean)
to get the locations of the mids of each bar group.

Opinions?

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```