Skip to content

Time Series x-axis labeling

2 messages · KarstenW, Gabor Grothendieck

#
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:
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.
#
Try this:

plot(tsData, ylab="Values", xlab="Zeit", xaxt = "n")
axis(1, time(tsData), rep(substr(month.abb, 1, 1), length = length(tsData)),
	cex.axis = .3, tcl = -.5)
jan <- time(tsData)[cycle(tsData) == 1]  # january
axis(1, jan, FALSE, tcl = -1)
abline(v = jan, lty = 2)

and also look at the example with main = "Fancy X Axis" in

library(zoo)
?plot.zoo
example(plot.zoo)
On Mon, Sep 8, 2008 at 3:03 PM, KarstenW <K.Weinert at gmx.net> wrote: