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

Gabor Grothendieck ggrothendieck at gmail.com
Mon Mar 27 17:29:18 CEST 2006


See plotCI in package gplots.

For dates you can make use of the builtin vector month.abb

plot(1:3, 11:13, xaxt = "n")
axis(1, 1:3, month.abb[1:3])

or use Date class:

xvals <- seq(as.Date("2006-01-01"), length = 3, by = "month")
plot(xvals, 1:3)

or with specific control over x axis:

xvals <- seq(as.Date("2006-01-01"), length = 3, by = "month")
plot(xvals, 1:3, xaxt = "n")
axis(1, xvals, format(xvals, "%b"))

More on dates is in the Help Desk article on R News 4/1.


As an aside, note that xlim=range(xvals) is a bit more compact..


On 3/27/06, Sean Davis <sdavis2 at mail.nih.gov> wrote:
>
>
>
> On 3/27/06 6:55 AM, "toby at abdn.ac.uk" <toby at abdn.ac.uk> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list