[R] Help: barchart() {lattice}

Francisco J. Zagmutt gerifalte28 at hotmail.com
Sat Dec 5 02:04:26 CET 2009


Hello Xin,

Take a look at the examples under ?print.trellis

Using your original example, you could use:

require(lattice)
p1=barchart(yield ~ variety | site, data = barley,
          groups = year, layout = c(1,6),
          ylab = "Barley Yield (bushels/acre)",
          scales = list(x = list(abbreviate = TRUE,
                        minlength = 5)))
p2=barchart(yield ~ variety | site, data = barley,
          groups = year, layout = c(1,6), stack = TRUE,
          ylab = "",
          scales = list(x = list(rot = 45)))  #I removed the legend and 
ylab to make it look a bit better


print(p1, split=c(1,1,2,1), more=TRUE)
print(p2, split=c(2,1,2,1))


I hope this helps,

Francisco

Francisco J. Zagmutt
Vose Consulting
1643 Spruce St., Boulder
Boulder, CO, 80302
USA
www.voseconsulting.com

Xin Ge wrote:
> Hi All,
> 
> I'm trying par(mfrow(c(1,2))) with barchart(), but its not working. Can I
> display two or more barcharts on a same page using some other function? I'm
> using following code --- where barchart() part is taken from help manual.
> 
> library(lattice)
> par(mfrow=c(1,2))
> barchart(yield ~ variety | site, data = barley,
>          groups = year, layout = c(1,6),
>          ylab = "Barley Yield (bushels/acre)",
>          scales = list(x = list(abbreviate = TRUE,
>                        minlength = 5)))
> barchart(yield ~ variety | site, data = barley,
>          groups = year, layout = c(1,6), stack = TRUE,
>          auto.key = list(points = FALSE, rectangles = TRUE, space =
> "right"),
>          ylab = "Barley Yield (bushels/acre)",
>          scales = list(x = list(rot = 45)))
> par(mfrow=c(1,1))
> 
> Thanks,
> Xin
> 
> 	[[alternative HTML version deleted]]
>




More information about the R-help mailing list