[R] error bars on barplots

Paul Murrell pm254 at medschl.cam.ac.uk
Fri Aug 27 12:28:12 CEST 1999


hi


---SNIP---
I'm trying to put error bars onto a barplot. I've tried something that
Bill Simpson suggested a while ago, ie:

x<-c(1,2,3,4,5)
y<-c(1.1, 2.3, 3.0, 3.9, 5.1)
ucl<-c(1.3, 2.4, 3.5, 4.1, 5.3)
lcl<-c(.9, 1.8, 2.7, 3.8, 5.0)
plot(x,y, ylim=range(c(lcl,ucl)))
arrows(x,ucl,x,lcl,length=.05,angle=90,code=3)
#or
segments(x,ucl,x,lcl)

but I can't get it to work on a barplot. Any ideas?
---SNIP---


i think the problem here is the fact that barplot decides for itself what
the x-locations of the bars are going to be.  fortunately, barplot returns
what it decides to use for the x-locations (this is described in the help
for barplot).  for example ...

y <- 1:10
x <- barplot(y)
segments(x, y-.2, x, y+.2)

hope that helps

paul




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