[R] lattice barchart() with two variables

Rich Shepard r@hep@rd @end|ng |rom @pp|-eco@y@@com
Fri Aug 24 23:31:06 CEST 2018


On Fri, 24 Aug 2018, Richard M. Heiberger wrote:

> color for the legend comes from trellis.par.get
> You can control that for an individual plot with the par.settings argument.
> tmp <- data.frame(y=sample(10),
>                  group=rep(c("Median", "Maximum"), each=5),
>                  year=factor(rep(1998:1999, length=10)))
>
> barchart(y ~ year, data=tmp, group=group, auto.key=TRUE, main="default legend",
>         col = c('grey','black'))
>
> barchart(y ~ year, data=tmp, group=group, auto.key=TRUE, main="what you want",
>         par.settings=list(superpose.polygon=list(col=c('grey','black'))))
>
> names(trellis.par.get())
> trellis.par.get()$superpose.polygon

   Thanks, Richard!

   Before venturing into par.settings I worked off of Bert's advice and
careful reading of the ?xyplot details allowed me to fix the two remaining
issues. Your suggestions will definitely be of value when I have other
complex lattice plots to properly display.

Best regards,

Rich




More information about the R-help mailing list