A few days ago, my colleague told me that he had a question about the double box plot. I was very glad and welcomed his question, but soon disappointed, a little. He wanted two colored standard box plot on one graph. Not a double axes box plot.
Well, that is another good question. I had also learned how to plot a chart with R by reading web articles, so it is my turn to write some.
Let’s generate two series of random data, with an outlier.
a <- rnorm(10) b <- c(rnorm(9), 4)
Draw a box plot without colors.
Now, color it with col= option.
boxplot(a, b, col=c('powderblue', 'mistyrose'))
It just paints inside of boxes. What about other parts?
boxplot(a, b, col=c("#FF000099", "#FF6D0099"), medcol=c("#FFDB00FF", "#B6FF00FF"), whiskcol=c("#49FF00FF", "#00FF24FF"), staplecol=c("#00FF92FF", "#00FFFFFF"), boxcol=c("#0092FFFF", "#0024FFFF"), outcol=c("#4900FFFF", "#B600FFFF"), outbg=c("#FF00DB66", "#FF006D66"), outcex=3, outpch=21)
For many (unknown) sets of data, I love using the function rainbow().
x <- rep(1:10, each=7) y <- rnorm(10*7) boxplot(y~x, col=rainbow(length(unique(x))))
c1 <- rainbow(10) c2 <- rainbow(10, alpha=0.2) c3 <- rainbow(10, v=0.7) boxplot(y~x, col=c2, medcol=c3, whiskcol=c1, staplecol=c3, boxcol=c3, outcol=c3, pch=23, cex=2)