[R] Time Series x-axis labeling

KarstenW K.Weinert at gmx.net
Mon Sep 8 21:03:57 CEST 2008


Hello,
how is it possible to plot a time series of monthly data over several years
such that the x-axis shows the first letter of the month and displays a grid
line at every year? I am new to R and had no real success until now. I have:

> library(utils)
> oneMonth = 1.0 / 12.0
> tsData = ts(rnorm(103,100), start=2000, deltat=oneMonth) # goes until Jul
> 2008, real data
> plot(tsData, ylab="Values", xlab="Zeit", axes=FALSE)
> axis(2) # as is
> atX=seq(from=time(tsData)[1], to=time(tsData)[length(tsData)],
> by=oneMonth)
> labMonths= c("J","F","M","A","M","J","J","A","S","O","N","D")
> labX = rep(labMonths, length.out=length(tsData))
> axis(1, at=atX, label=labX)

But here I am stuck. First, I do not know how to add the years. And then, I
would like to show all the labels, but only few of the months are displayed.

Any hint appreciated,
kind regards,
Karsten.
-- 
View this message in context: http://www.nabble.com/Time-Series-x-axis-labeling-tp19378906p19378906.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list