Skip to content
Prev 350295 / 398506 Next

R lattice bwplot: Fill boxplots with specific color depending on factor level

Pablo,

I would do it similarly.  I would also place the box and whiskers in
the specified colors.

## install.packages(HH)  ## if you don't have it
library(HH)

bwplot(mydata$Col1~mydata$Col3 | mydata$Col2,data=mydata,
       groups = Col3,
       as.table = TRUE, # added to make it easier for factor levels
       layout = c(3,1), # looks nicer and easier to read
       panel = panel.bwplot.superpose,
       col = c(red,"darkorange",green),
       fill = c(red,"darkorange",green), fill.alpha=.6)

I changed your amber to "darkorange" as the amber lines are almost invisible.

Rich
On Wed, Apr 22, 2015 at 9:26 PM, Duncan Mackay <dulcalma at bigpond.com> wrote: