[R] lattice xyplot - aligning date labels so that they align with the grid lines in panel.grid

john.gavin at ubs.com john.gavin at ubs.com
Mon Jun 19 19:50:14 CEST 2006


Hi,

I have a basic question about aligning date labels for the x-axis
in an xyplot so that they align with the grid lines
from the panel.grid argument.

For example, with

x <- data.frame(
  date = seq(as.Date("2005/01/01"), as.Date("2006/06/01"), 
  length.out = 20), value = runif(20))
xyplot(value ~ date, data = x,
  panel = function(x, y, subscripts, ...)
  { panel.grid(h = -1, v = -1, col = "grey", lwd = 1, lty = 1)
    panel.xyplot(x, y, ...)
  }) 

How can I get the labels on the x-axis to align 
with the vertical grid lines?
i.e. I have 6 vertical grid lines by default (v = -1)
in this example so I would like 6 labels along the x-axis
at the same points, whereas I see only 2 (2005 and 2006).

As an alternative I would be happy to just specify the number of labels
as long as panel.grid's vertical lines aligned with the labels.

> R.version.string
[1] "Version 2.3.1 (2006-06-01)"

on Windows NT4.

Regards,

John.

John Gavin <john.gavin at ubs.com>,
Commodities, FIRC,
UBS Investment Bank, 2nd floor, 
100 Liverpool St., London EC2M 2RH, UK.
Phone +44 (0) 207 567 4289
This communication is issued by UBS AG or an affiliate ("UBS...{{dropped}}



More information about the R-help mailing list