Re: [R] Lattice barchart with different fill pattern

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Tue 15 Aug 2006 - 00:34:57 EST

On 8/14/06, Rafael Duarte <rduarte@ipimar.pt> wrote:
> Dear list,
> I am new to lattice plots.
> I want to make a barchart with 10 and more levels.
> I need to use a grey scale for printing purposes.
>
> The problem is that with 10 or more levels in factors it is very
> difficult to distinguish each level in the plot and legend, since the
> greys are very similar (some levels have value of zero and don't appear).
>
> Here is an example of my problem:
>
> df <- data.frame("year" = rep(1996:2005,10),
> "spe" = c(rep("aa",10), rep("bb",10), rep("cc",10), rep("dd",10),
> rep("ee",10), rep("ff",10), rep("gg",10),
> rep("hh",10),rep("ii",10),rep("jj",10)),
> "value" = sample( c(0:10),100 , replace=TRUE)
> )

Nothing to do with your problem, but 'rep' has an argument 'each' which would shorten the call above.

> require("lattice")
> barchart( value ~ factor(year), groups = spe, data=df, stack = TRUE,
> main="", xlab="",
> auto.key = list(points = FALSE, rectangles = TRUE, space =
> "right" ),
> par.settings = list(superpose.polygon = list(col =
> gray.colors(10) ), scales = list(cex=0.8, rot=c(90,0,0)))
> )
>
> I was thinking that by changing the fill pattern, the different levels
> could be better distinguished.
>
> I have read the lattice help and searched in the mailing list archives,
> but did no find any solution for lattice barchart.
>
> Is there a way to change the fill pattern of the bar levels or any other
> approach to help in the identification of the different levels in the
> barchart?

Unfortunately, no. lattice depends on the grid package for rendering, and last time I checked, grid didn't have support for fill patterns.

Deepayan



R-help@stat.math.ethz.ch 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. Received on Tue Aug 15 00:43:20 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 15 Aug 2006 - 02:23:28 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.