[R] bwplot puts the bars in the wrong place

James Rome jamesrome at gmail.com
Sat Apr 17 03:37:14 CEST 2010


On 4/16/2010 8:27 PM, Jun Shen wrote:Jim,

Try this,

bwplot(tt~as.factor(OnHour),data=gdf,......)

Jun Shen from Millipore

I already tried using a factor, and the data set I enclosed had
gdf$OnHFact which was already a factor. It gave the same wrong plot.

What did work was to call xyplot instead of bwplot, and to use
panel.bwplot in the panel function:

        hrs = seq(0, 23, 1)
       hrlabs = as.character(seq(0,23,1))   
        g = xyplot(gdf$tt~gdf$OnHour |gdf$Runway, data=gdf, ylab="Taxi
time (min)", main=title, xlab="Hour of day",
            xlim=c(-1, 24), scales=list(x = list(rot=90, cex=.6,
alternating=c(3,3,3,3),
            at=hrs, labels=hrlabs
            )),                                   
            panel=function(x, ...) {
                panel.grid(h = -1, v = 24)
                panel.bwplot(x, horizontal=FALSE, col="black",...)   
                               
            }
        )
        print(g)                                                   

But I do not understand why this makes a difference. It has something to
do with the fact that there are no data for some of the hours.
The difference between the calls  is either a bug, or it should be in
the documentation somewhere obvious. I spent a week on this.

Thanks,
Jim Rome

Thanks,
Jim Rome



More information about the R-help mailing list