I have a data similar to this and then produce a boxplot using lattice:
mydata <- data.frame(Y = rnorm(3*1000),
INDFACT =rep(c("A", "B", "C"), each=1000),
CLUSFACT=factor(rep(c("M","F"), 1500)))
library(lattice)
bwplot(Y ~ INDFACT | CLUSFACT, data=mydata, layout=c(2,1))
My question is that I want to have a different color for each factor A, B and C. I have tried this:
bwplot(Y ~ INDFACT | CLUSFACT, data=mydata, layout=c(2,1), col=c("red","blue","green"))
But it just changes the color of the dots. What I want is to change the whole color (of the dot, the box and the umbrella).
Is there a way to do that?
So you wanted to change the umbrella and the dot and the box, but didn’t say whether it was the fill of the rectangle. I’m going to guess it was the rectangle line, because doing both the fill and the dot wouldn’t make sense.