[R] X Axis labeling with class zoo

Gabor Grothendieck ggrothendieck at gmail.com
Thu Oct 25 03:15:35 CEST 2007


Use the panel= argument as shown in the examples section of ?plot.zoo

On 10/24/07, John Theal <jtheal at free.fr> wrote:
> 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?
>
> ______________________________________________
> 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