Skip to content

plotting time series with zoo pckg

2 messages · AA, Gabor Grothendieck

AA
#
Hi all,

I am using the zoo package to plot time series. I have a problem with formatting the axes.
my zoo object (z) looks like the following.

                c1      
1992-01-10     21     
1992-01-17     34     
1992-01-24     33  
1992-01-31     41     
1992-02-07     39     
1992-02-14     38     
1992-02-21     37    
1992-02-28     28     
1992-03-06     33     
1992-03-13     40  

plot.zoo(z) produces a plot with the labels on the x-axis that I cannot control.
I want a an xtick every 10 data points with corresponding date labels.
I have tried different combination of axis command without success
any idea?
Thanks
#
Try this:


# test data
library(zoo)
z <- structure(c(21, 34, 33, 41, 39, 38, 37, 28, 33, 40),
     index = structure(c(8044, 8051, 8058, 8065, 8072, 8079, 8086,
     8093, 8100, 8107), class = "Date"), class = "zoo")
z

# plot without X axis
plot(z, xaxt = "n")

# unlabelled tick at each point
axis(1, time(z), lab = FALSE)

# labelled tick every third point
dd <- time(z)[seq(1, length(z), 3)]
axis(1, dd, as.character(dd), cex.axis = 0.7, tcl = -0.7)
On 12/26/06, ahmad ajakh <aajakh at yahoo.com> wrote: