[R] X Axis labeling with class zoo
John Theal
jtheal at free.fr
Wed Oct 24 22:48:42 CEST 2007
I'm using zoo to plot multiple data series, however, I am having
trouble adjusting the x-axis labeling on a multiple series plot. For
example, if I create a zoo
object that consists of a date series and a numerical series and then
plot it, I can adjust the x axis labeling using
axis.Date(1, at=seq(as.Date("1984/01/31"), as.Date("2005/10/31"),
by="2 years"))
and I get my x axis labels every two years. However, if my zoo
object contains multiple (i.e. 3) series and I plot my data so that I
get a plot window with three sub-plots (one for each series), I
cannot adjust the x axis labeling using the above line of code.
That is, the following does not seem to work:
# create the zoo object
MySeries <- cbind(RCPTOI, RNCPTOI, NRPTOI)
MyZooSeries <- zoo(MySeries, Dates)
# construct a plot
plot(MyZooSeries, type="l", col="red", xaxs="i", xaxt="n")
axis.Date(1, at=seq(as.Date("1984/01/31"), as.Date("2005/10/31"),
by="2 years"))
In this case, the axis.Date command does nothing to adjust the plot.
For multiple series, do the axes indices change?
More information about the R-help
mailing list