[R] Same boxplot colors by panels in lattice (bwplot)

Concha Bielza mcbielza at fi.upm.es
Sun Apr 7 22:45:05 CEST 2013


Dear all,

I would like to have the same color for the all boxplots from the same 
panel, but my code below shows the two colors alternating. Thanks!

set.seed(42)
D1 <- rnorm(200)
D2 <- factor(sample(letters[1:2],200,TRUE))
D3 <- factor(sample(letters[3:5],200,TRUE))
DF <- data.frame(x=D1,a=D2,b=D3)
print(bwplot(b~x|a,data=DF,col=c("black","black"),
              par.settings = list(box.rectangle = 
list(fill=c("darkorange1","limegreen"))),
              panel=function(x,...,col) {
              panel.bwplot(x,...,col=col[packet.number()])
                                        }
             )
      )

Thanks,
Concha



More information about the R-help mailing list