On 9/10/07, jim holtman <[EMAIL PROTECTED]> wrote: > I am using 'xyplot' in lattice to plot some data where the x-axis is a > POSIXct date. I have data which spans a 6 month period, but when I > plot it, only the last month is printed on the right hand side of the > axis. I would have expected that at least I would have a beginning > and an ending point so that I have a point of reference as to the time > that the data spans. Here is some test data. > > > > # create test data > > dates <- seq(as.POSIXct('2006-01-03'), as.POSIXct('2006-06-26'), by='1 > > week') > > my.data <- seq(1, length=length(dates)) > > require(lattice) > [1] TRUE > > # plot only shows a single month ("Jul" on the right). Would have > > # expected at least the beginning and the ending month since this spans > > # a 6 month period > > pdf('/test.pdf') > > xyplot(my.data ~ dates) > > dev.off()
Yes, the calculations seem very sensitive to the exact range (probably because you are close to the beginning of a year); e.g., the first two seem fine, but things are not nice for anything bigger. xyplot(my.data ~ dates, lattice.options = list(axis.padding = list(numeric = 0))) xyplot(my.data ~ dates, lattice.options = list(axis.padding = list(numeric = 0.01))) xyplot(my.data ~ dates, lattice.options = list(axis.padding = list(numeric = 0.02))) Your options are (1) specify tick locations manually, using scales$x$at -- this should work, but I haven't checked (2) provide a patch for lattice:::formattedTicksAndLabels.POSIXct that gives behaviour that you like The current version is derived from axis.POSIXct, which, incidentally, can also be made to do odd things: dates <- c(as.POSIXct('2005-12-30'), as.POSIXct('2006-07-01')) my.data <- seq(1, length=length(dates)) plot(dates, my.data) -Deepayan ______________________________________________ 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.