[R] Lattice zoo plot: no x ticks on first panel

From: SIES 73 <enrique.bengoechea_at_credit-suisse.com>
Date: Tue, 27 May 2008 13:16:26 +0200

Hi all,  

I want to use lattice v0.17-4 on R 2.6.2 to draw a panel of time series of zoo objects (zoo v1.5-0). Everything works until I try to separate panels a bit and show only the bottom axis line with tick marks on every panel (but not axis labels, which I want only on the bottom panels).  

I've tried several approachs, and the best I've got for showing only the bottom axis line and ticks is to set the 'axis.line' color in 'par.settings' to "transparent", then build the axis manually invoking panel.abline() and panel.axis() on a custom panel function. The problem is that, with this combination of parameters, axis ticks are never drawn on the *first* panel (bottom or top depending on the value of 'as.table'), but are correctly shown in all other panels.  

I can overcome the problem using trellis.focus() and panel.axis() after drawing the panels, but it does not update the resulting trellis object, which I need to store for later printing/plotting, so I think I need to do it on the custom panel function (unless I'm missing some other feature of lattice...)  

Below is the minimal code I've found to replicate the issue, as well as my environment configuration. Any help appreciated.  




my.panel <- function(x, y, subscripts, groups, panel=panel.xyplot, ...) {   opar <- trellis.par.get("clip");
  trellis.par.set(clip=list(panel="off", strip="off"));   on.exit(trellis.par.set(opar));

  panel.abline(h=current.panel.limits()$ylim[1], col="black", lwd=1, lty=1);   lAxis <- lattice:::calculateAxisComponents(x);   panel.axis(side="bottom", line.col="black", at=lAxis$at,     ticks=TRUE, draw.labels=FALSE, outside=TRUE, check.overlap=FALSE);   panel.plot.default(x=x, y=y, subscripts=subscripts, groups=groups, panel=panel, ...); }

z <- zoo(cbind(a = 1:5, b = 11:15, c = 21:25) + rnorm(5))

zoo:::xyplot.zoo(z, panel=my.panel, between=list(x=1.2, y=1), par.settings=list(axis.line=list(col="transparent")))

> sessionInfo()

R version 2.6.2 (2008-02-08)


attached base packages:
[1] grid stats graphics grDevices utils datasets methods base

other attached packages:
[1] zoo_1.5-0 lattice_0.17-4 rcom_1.5-2.2

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. Received on Tue 27 May 2008 - 11:21:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 27 May 2008 - 14:30:39 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive