[R] Error Bars

Ben Bolker ben at zoo.ufl.edu
Thu Nov 8 10:29:47 CET 2001


  there's a simple solution.  barplot returns the locations of the
horizontal centers of the bars, so replace your last two lines with
something like:

bloc <- barplot(thing, ylim=c(0,4))
arrows(bloc, thing-se, bloc, thing+se, code=3, angle=90,length=0.1)

On Thu, 8 Nov 2001, Anon. wrote:

> I'm trying to draw some error bars on a bar chart.  I'm using code like
> this:
>
> thing <- c(3,3,3)
> se <- c(1,1,1)
> names(thing) <- c("A", "B", "C")
> barplot(thing, ylim=c(0,4))
> arrows(c(1:3), thing-se, c(1:3), thing+se, code=3, angle=90,length=0.1)
>
> Using c(1:3) has 2 problems:
> 1. Obviously it is untidy, but using names(thing) doesn't work, and I
> can't find out what will work.
> 2. It draws the lines in the wrong place (i.e. not in the middle of the
> bars)
>
> I'm sure this problem has a well know and obvious solution, but it's not
> so well known or obvious to me.
>
> Thanks in advance.
>
> Bob
>
>

-- 
318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list