[R] Lattice barchart with different fill pattern

Rafael Duarte rduarte at ipimar.pt
Mon Aug 14 16:11:53 CEST 2006


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)
  )

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?

Many thanks.

Rafael Duarte

OS: windows XP



More information about the R-help mailing list