On Wed, Nov 9, 2011 at 4:33 AM, thierrydb <thierr...@gmail.com> wrote: > I would like to add vertical shaded blocks in plot.xts graphs (like recession > periods in FRED graphs) > > The reason I use plot.xts instead of plot.zoo is that I like the fact that > the grid is automatically aligned with major ticks in plot.xts. > > xblocks() and rect() do not seem to work with plot.xts (only with plot.zoo). > Are there any alternative methods that work with plot.xts? >
Just suppress one or both axes and then draw them with their grid in exactly the same way that you would in R classic graphics. Its only one or two extra statements depending on whether you want one or both: library(zoo) z <- zooreg(1:25, Sys.Date()) plot(z, type = "o", xaxt = "n", yaxt = "n") abline(v = Axis(time(z), side = 1), lty = 2, col = grey(.5)) # X abline(h = Axis(coredata(z), side = 2), lty = 2, col = grey(.5)) # Y -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ R-help@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.