Skip to content
Prev 156972 / 398506 Next

lattice: Color in Barchart legend

Dear list,

with the code below I produce the right graph, but the colours of the  
legend are different from the colours of the graph. The colours of the  
graph are the desired colours.

Thanks for any help.
Patrick

library(lattice)

pal1 <- rgb(196, 255, 255, max = 255)
pal2 <- rgb(  0,  35, 196, max = 255)

df <- data.frame( Gruppe = c("A", "B", "A", "B"),
             Kat = c("x1", "x1", "w1", "w1"),
             value= c(1,2, 4, 5))

barchart(value ~ Kat, group= Gruppe,
          panel = function(y,x,...){
          panel.barchart(x,y, ..., col=c(pal1, pal2))
          }, data = df,
              auto.key = list(points = FALSE, rectangles = TRUE,
                         columns = 2, space = "bottom")
)