[R] duplicate DATE at in lattice scale handled differently from base graphics OR lattice numeric scales

Alex Brown alex at transitive.com
Mon Jul 30 18:51:17 CEST 2007


When at, label chains contain duplicate at values, axis ticks are  
dropped.  I believe this is handled incorrectly for Date ats in  
lattice 0.15-4 when compared to how it is handled for numeric, or for  
dates in base plot.  This can result in mis-labelled axes in some  
circumstances.  I have included executable examples.

R: 2.5.0

numeric base plot:

plot(1:10, axes=F); axis(1, at=c(2,4,4,6), labels=letters[1:4])

shows labels a, b, d

date scale in base plot:

plot((as.Date("2007-01-01") + 1:10), 1:10, axes=F); axis(1, at= 
(as.Date("2007-01-01")+c(2,4,4,6)), labels=letters[1:4])

shows labels a, b, d

numeric scale in lattice plot

xyplot(1:10 ~ 1:10, scales=list(x=list(relation="free", at=c 
(2,4,4,6), labels=list(letters[1:4]))))

shows labels a, b, d

date scale in lattice plot

xyplot(1:10 ~ (as.Date("2007-01-01") + 1:10) , scales=list(x=list 
(relation="free", at=list(as.Date("2007-01-01")+c(2,4,4,6)),  
labels=list(letters[1:4]))))

shows labels a, b, c

Since this results in label c being placed at position 6, not 4, I  
feel this is a bug.

-Alex Brown



More information about the R-help mailing list