[R] questions about plot.zoo

Gabor Grothendieck ggrothendieck at gmail.com
Thu Dec 27 06:33:26 CET 2007


There is an example in the example section of ?plot.zoo .  That
example is for a multipanel plot but the same idea works for
a single panel plot -- in that case you don't have to define a panel
but can just use axis directly.

On Dec 27, 2007 12:28 AM, tom soyer <tom.soyer at gmail.com> wrote:
> Thanks Gabor!
>
> Also, can you give an example of customizing the major tick marks on the
> x-axis and adding minor tick marks between major tick marks?
>
>
>
> On 12/26/07, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> > On Dec 26, 2007 10:55 PM, tom soyer <tom.soyer at gmail.com> wrote:
> > > I have been having very good results using plot.zoo to chart time series
> > >[...]
> > > (1) when I tried to use semi-log scale, via log="y", R issued a warning,
> > > although it looked like plot.zoo plotted in semi-log scale anyway:
> > >
> > > Warning message:
> > > In plot.xy(xy.coords(x, y), type = type, ...) :
> > >  "log" is not a graphical parameter
> > > Does anyone know if I should ignore the warning, or discard the semi-log
> > > looking graph instead?
> >
> > 1. plot.zoo is passing the log= argument to the panel and in this case
> > panel=lines.  You can (a) ignore the warning, (b) use suppressWarnings
> > or (c) use a custom panel which excludes log:
> >
> > lines2 <- function(...) { L <- list(...); L$log <- NULL; do.call(lines, L)
> }
> > z <- zoo(1:100)
> > plot(z, log = "y", panel = lines2)
> >
> > > (2) I noticed that plot.zoo automatically generates major tick marks for
> the
> > > user. But does anyone know how to customize the major tick marks on the
> > > y-axis, and adding minor tick marks between them? I tried both axis()
> and
> > > minor.tick in the Hmisc package, but could not make them work. It seems
> that
> > > axis() and minor.tick do not work well with dates.
> >
> > 2.  If you are using a single panel then try this:
> > plot(z, yaxt = "n")
> > axis(2, c(1, 10, 100))
> >
> > >
> > > (3) I tried to add horizontal grid like this:
> > >
> > > x=axis(4)
> > > abline(h=x,col="light gray")
> > >
> > > It works... but unfortunately, the grid lines are all drawn on top, or
> in
> > > front, of the lines or bars of data on the chart. As a result, the grid
> > > lines cover up the lines of data when they cross each other. Does anyone
> > > know if it is possible to specify the order of lines on a chart, i.e.,
> > > something like the z-index, so that the grid lines are behind the data
> > > lines? If not, then what would be the proper way of adding gridlines so
> that
> > > thay are consistent with the major and minor tick marks?
> >
> > Try using xyplot.zoo.  See:
> > ?xyplot.zoo
> > for an example which specifically shows how to do it.
> >
>
>
>
> --
> Tom



More information about the R-help mailing list