[R] changing the x axis labels in a time series plot
Rui Barradas
ruipbarradas at sapo.pt
Sat Jul 14 13:06:19 CEST 2012
Hello,
Actually, axis() was doing its job, but you have xlim=1:100 and cannot
expect to see points at x=1322:1421. The correct way would be to say
that your time series starts at 1322 and that it records observations
with a frequency of 1. Then plot it. Just look. I've nclude an axis(9
call to make sure it works as instructed, meaaning, at=Year.
z <- cbind(1:100,100:1); Year = 1322:1421
zz <- ts(z, start=1322, frequency=1)
windows()
plot(zz, plot.type="single", xlab="Year", ylab="zz")
axis(3, at=Year)
Hope this helps,
Rui Barradas
Em 14-07-2012 10:54, Jim Bouldin escreveu:
> OK, this has to be simple but I've searched through help files, mailing
> list archives and well, everything I could think of, and still no luck.
>
> I simply want to change the x axis labels in a time series graph, from its
> default numbering (which starts at 1 and increments by 1), to values I have
> in another vector, "Year". It has to be a time series graph, I don't want
> to have to use a scatter plot because there are many lines to draw.
>
> Example:
>
> z = cbind(1:100,100:1); Year = 1322:1421
> windows()
> plot.ts(z[,1:2],,"single", xaxt="n", xlab="")
> axis(1,at=Year)
>
> This doesn't work, not any of the permutations I've tried with the various
> arguments to plot.ts and axis.
> Thanks for any help.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list