A plotting question - how to get error bars?

4 messages
Open this post in threaded view
|

A plotting question - how to get error bars?

 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? Any comments gratefully received! 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(x=xvals,y=rgrT1,boxplots=cbind(0,0,errbarsT1lo,errbarsT1up,0.5),inches=FALSE,add=TRUE)                 #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) symbols(x=xvals,y=rgrT2,boxplots=cbind(0,0,errbarsT2lo,errbarsT2up,0.5),inches=FALSE,add=TRUE) lines(x=xvals,y=rgrT2,lty=24) legend(x="right",c("Treatment 1","Treatment 2"),pch=c(21,24)) ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Open this post in threaded view
|

Re: A plotting question - how to get error bars?

 On 3/27/06 6:55 AM, "[hidden email]" <[hidden email]> wrote: > 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? First, do your plot with (..., axes=F).  Then, look at the help for axis() to put the axes on the plot. > 2. How to get "T"s on the end of my error bars like you have in standard > scientific plots? RSiteSearch('error bars') several answers that might be of interest. Sean ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide! http://www.R-project.org/posting-guide.html