[R] different x-axes in Lattice

Peter Ehlers ehlers at ucalgary.ca
Sun Jan 24 15:34:57 CET 2010


If I understand you correctly, then what you propose makes
very little sense to me. In your barley2 example, I certainly
would want to see the empty space for 'Velvet'. If you want a
separate plot for each site, with no common 'variety' axis,
then just build separate plots. Of course you would lose the
ability to easily scan the vertical direction to compare
varieties at different sites.

  -Peter Ehlers

Robert Ruser wrote:
> I use lattice package and 'barchart' to build a chart. I have a
> problem with setting different x-axes. Some x categories are missing
> but they are display and I don't want. I use scales = list(y =
> "free",x="free") but it works only for y-axes. Simple example:
> 
> package(lattice)
> barchart(yield ~ variety | site, data = barley,
>         groups = year, layout = c(1,6),
>         scales = list(y = "free",x="free"),
>         auto.key=list(rectangles = TRUE, space = "bottom"),
>         )
> 
> Let's assume that in the first panel  'Waseca'  the category 'Velvet'
> are not available in data but in the chart there is a empty place. If
> more categories are not available it looks bad. Simple modification to
> illustrate my problem:
> 
> barley2 <- barley[barley[,2]!="Velvet" | barley[,4]!="Waseca",]
> barchart(yield ~ variety | site, data = barley2,
>         groups = year, layout = c(1,6),
>         scales = list(y = "free",x="free"),
>         auto.key=list(rectangles = TRUE, space = "bottom"),
>         )
> 
> 
> Robert
> 
> ______________________________________________
> 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.
> 
> 

-- 
Peter Ehlers
University of Calgary



More information about the R-help mailing list