Mehrdad Shamsi
2010-Oct-11 17:41 UTC
[Rd] Lattice::bwplot unexpected behaviour when using vector of colors
Hi, I'm trying to produce colored boxplots using lattice::bwplot function. I need to plot each boxplot in the panel with a specific color. Naturally I used a vector of colors and expected to see colored boxplots. Although the boxplots were colored, the color of whiskers and the boxes do not match. Here is an example: d = data.frame(y = rnorm(100), x=1:4) box.color <- c('red','blue','black', 'green') bwplot(y~x, data=d, horizontal=FALSE, par.settings = list( box.rectangle = list(col = box.color), box.umbrella = list(col = box.color) ) ) I went through the bwplot.panel to figure out what the problem was. It seems that bwplot.panel function is implemented with the assumption that box.rectangle$col and box.umberella$col are not vectors. It would be nice if bwplot.panel could accept vector of colors. I use R2.11-x64 on a Windows XP machine. The lattice package version is lattice_0.19-13. --Thanks -- M.S.
Mehrdad Shamsi
2010-Oct-12 15:55 UTC
[R] Lattice::bwplot unexpected behaviour when using vector of colors
Hi, I posted this message on R-devel, but it seems to be more suitable for R-help. So I post it here again. I'm trying to produce colored boxplots using lattice::bwplot function. I need to plot each boxplot in the panel with a specific color. Naturally, I used a vector of colors and expected to see colored boxplots. Although the boxplots were colored, the color of whiskers and the boxes do not match. Here is an example: d = data.frame(y = rnorm(100), x=1:4) box.color <- c('red','blue','black', 'green') bwplot(y~x, data=d, horizontal=FALSE, par.settings = list( box.rectangle = list(col = box.color), box.umbrella = list(col = box.color) ) ) I went through the bwplot.panel to figure out what the problem was. It seems that bwplot.panel function is implemented with the assumption that box.rectangle$col and box.umberella$col are not vectors. It would be nice if bwplot.panel could accept vector of colors. I use R2.11-x64 on a Windows XP machine. The lattice package version is lattice_0.19-13. --Thanks -- M.S.