[R] lattice barchart using a time scale in x axis

RICHARD M. HEIBERGER rmh at temple.edu
Fri Feb 5 17:11:52 CET 2010


Fran,

The trick is to use box.width, not box.ratio.

xyplot(Perc ~ as.POSIXct(hora,format="%d-%m-%Y %H:%M"),
       data=digrate, groups=Drate, ## key=leg,
       xlab="time of the day",
       horizontal=FALSE,
        scales=list(alternating=FALSE,
          tck=c(1,0),
          x=list(at=seq(r[1],r[2],by="hour"),
        labels=format(seq(r[1],r[2],"hours"), format="%H"))),
       panel=function(...) {
         panel.fill(col="white")
         panel.grid(-1,0,lty=3,col="gray")
         panel.barchart(...)
       },
      main="xyplot", box.width=5000
      )

I also changed the color of the grid to gray.  I don't want the background grid
visually dominant.

Rich



More information about the R-help mailing list