On Thu, Jul 8, 2010 at 4:17 AM, Rainer M Krug <r.m.k...@gmail.com> wrote:
> Hi
>
> Let's assume, I have a dataset of 1000 datapoints, which represent daily
> recordings of a measurement.
> They are stored as a ts object (see example below)
>
> Now I want to represent them as a barplot. I found the barplot in the zoo
> package, but I have one problem: the x-axis labels. I would like to have the
> x-axis labels as either years only (located at the beginning of the year),
> or year/month. So my question:
>
> How can I set the x-axis labels to years
>
> I can change the start / end of the time series if necessary or use another
> barplot.
>
> Below find a small example:
>
> library(zoo)
> x <- ts(runif(1000), start=c(2000, 150), frequency=365)
> barplot(zoo(x))
>
>

Try this:

library(zoo)
plot(as.zoo(x), type = "h", xaxt = "n")
axis(1, unique(floor(time(x))))

or this:

plot(x, type = "h", xaxt = "n")
axis(1, unique(floor(time(x))))

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to