Skip to content
Back to formatted view

Raw Message

Message-ID: <20080924123727.o4lrv69k0k0wow4k@webmail.uni-bremen.de>
Date: 2008-09-24T10:37:27Z
From: Patrick Hausmann
Subject: 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")
)