# [R] A plotting question - how to get error bars?

toby at abdn.ac.uk toby at abdn.ac.uk
Mon Mar 27 13:55:42 CEST 2006

```Dear R list,

Can anyone help with a plotting question? I'm trying to display some data
on a plot and I've almost got the format I need (see code below), but 2
things I can't get:

1. How to get "Jan","Feb","Mar" on the x=axis instead of 1:3?
2. How to get "T"s on the end of my error bars like you have in standard
scientific plots?

Thanks,
Toby

xvals=1:3	#couldn't get it to be "Jan, Feb, Mar" on the x-axis
rgrT1=c(10,20,30)
errbarsT1lo=c(0.5830952,0.3741657,0.8944272)
errbarsT1up=errbarsT1lo
rgrT2=c(25,30,35)
errbarsT2lo=c(1.356466,3.535534,1.140175)
errbarsT2up=errbarsT2lo
minx=min(xvals);maxx=max(xvals)
miny=min(rgrT1-errbarsT1lo,rgrT2-errbarsT2lo);maxy=max(rgrT1+errbarsT1up,rgrT2+errbarsT2up)
plot(x=0,y=0,type="n",xlim=c(minx,maxx),ylim=c(miny,maxy),lab=c(2,20,0),bty="l",xlab="month",ylab="Relative
Growth Rate")
points(x=xvals,y=rgrT1,pch=21)
#symbols does the error bars, but without the "T"s at the end. The
boxplot command does the Ts, but you can't have them without the box in
the middle (and you can't have different symbols for points either)
lines(x=xvals,y=rgrT1,lty=21)
points(x=xvals,y=rgrT2,pch=24)