[R] axis date format in lattice

From: <karl.sommer_at_dpi.vic.gov.au>
Date: Thu 11 Jan 2007 - 01:07:00 GMT


Hello list,

plotting the following example 1 in lattice only labels the x-axis with one tick mark at the beginning of February.
In contrast the standard plot() function labels the x-axis with equally spaced tick marks.

#----example 1 -------
library(lattice)
date <- as.Date(c("1/10/2006", "01/11/2006", "01/12/2006",

"01/01/2007", "01/02/2007"),format="%d/%m/%Y")
xx <- c(1,3,5,6,7)
xx1 <- as.data.frame(cbind(date, xx))
xyplot(xx~date, scales=list(x=list(format = "%b"))) plot(xx~date)

Interestingly the behaviour in lattice only seems to arise when there is a change in calendar years. This is demonstrated by the second example with dates from within 1 calendar year only where lattice works as expected.

I was wondering if the behaviour in example 1 was due to a bug or am I missing something and, more importantly, is there a way around it?

#---example 2 -------
date <- as.Date(c("1/08/2006", "01/09/2006", "01/10/2006",

"01/11/2006", "01/12/2006"),format="%d/%m/%Y")
xx <- c(1,3,5,6,7)
xx1 <- as.data.frame(cbind(date, xx))
xyplot(xx~date, scales=list(x=list(format = "%b"))) plot(xx~date)

Cheers
Karl



Dr Karl J Sommer,
Department of Primary Industries,
Catchment & Agriculture Services,
PO Box 905
Mildura, VIC, Australia 3502

Tel: +61 (0)3 5051 4390
Fax +61 (0)3 5051 4534

Email: karl.sommer@dpi.vic.gov.au



R-help@stat.math.ethz.ch 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 Thu Jan 11 12:13:16 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 11 Jan 2007 - 01:30:25 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.