[R] bwplot puts the bars in the wrong place

James Rome jamesrome at gmail.com
Mon Apr 19 16:27:54 CEST 2010


You were right about the gdf$. Something else must have been giving me
the errors.

So I tried it with your scale suggestion:
        hrs = seq(1, 24, 1)            
        hrlabs = as.character(seq(0,23,1))
            g = bwplot(tt~OnHour |Runway, data=gdf, horizontal=FALSE,
ylab="Taxi time (min)",
            main=title, xlab="Hour of day", 
par.strip.text=list(cex=0.7), rot=90,  xlim=c(0, 25),
            scales=list(x = list(rot=90, cex=.6
            ,at=hrs, labels=hrlabs
            )),
            panel = function(x, ...) {
                panel.grid(h = -1, v = -1)                           
                               
                panel.bwplot(x, ...)                                   
                                                                       
                                   
          } )
        print(g)
And now the bars for hour 23 are missing

On 4/17/2010 4:16 PM, Peter Ehlers wrote:James,

Your problem with bwplot is with your scales definition.
bwplot places the plots at locations 1:24; you can then
supply arbitrary labels for these locations. Try changing
the following:

 xlim = c(-1, 24) to xlim = c(0, 25)
 at = hrs to at = hrs + 1 (or redefine hrs)

As to needing to use 'gdf$': this makes no sense to me.
What error occurs if you leave that off?

 -Peter Ehlers

On 2010-04-17 13:00, James Rome wrote:
> David,
>
> I did post a solved message:
>          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)
> created the plot I sent you (withxyplot.png), with the 0 data plotted on
> zero, and the 3AM data blank.
>
> I arrived at this by doing xyplot and observing that the points were
> plotted correctly. Then I added panel.bwplot() and it was still correct,
> so I removed panel.xyplot() and it worked. But replacing the main call
> to xyplot with bwplot gets it wrong.
> For example, I did it with
>
>          hrs = seq(0, 23, 1)
>          hrlabs = as.character(seq(0,23,1))
>          g = bwplot(gdf$tt~gdf$OnHFact |gdf$Runway, data=gdf, ylab="Taxi
> time (min)", main=title, xlab="Hour of day",
>              xlim=c(-1, 24), horizontal=FALSE, drop.unused.levels=FALSE,
>              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,
> col="black",...)
>              }
>          )
>          print(g)
> and get the attached withbwplotAndFactors.png, which is wrong. It was
> also wrong with OnHour, and with drop.unused.levels=TRUE.
>
> And I did indeed get errors if I left the gdf$ out of the formulas,
> because it is defined in many data frames.
>
> Thanks,
> Jim
>
> On 4/17/2010 12:35 PM, David Winsemius wrote:
> On Apr 17, 2010, at 12:29 PM, James Rome wrote:
>
>> It has all the data needed, and only that data, which I got dinged on
>> before.
>
> I was seeing a different number of points in some panels in your plot
> compared to my plot. I have not downloaded the most recent dataset, and
> from what you are saying here should  I assume it had not changed? But
> your plot had a title that could not have been created by the posted
> code , so i just don't know where you are with all of this. Are you
> going to post a SOLVED message when it is finally answered?
>
>
>
>
>
> ______________________________________________
> R-help at 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: bwplot1-24.PNG
Type: image/png
Size: 49115 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100419/bf9a9c2c/attachment.png>


More information about the R-help mailing list