Skip to content
Prev 378249 / 398502 Next

Colors on box plots in ggplot

You have not mapped an aesthetic to colour, so the scale (which applies to an aesthetic) is not being used at all.

Try    
( p <- ggplot(ToothGrowth, aes(x=dose, y=len))  + geom_boxplot(aes(colour=dose)) )

which uses default colours. Once you have an aes  mapping you can change the scale, so 
 (     p + scale_colour_manual(values = c("red", "blue", "green")) )

gives you the colour ordering you want.

(     p + scale_colour_manual(values = c("red", "blue", "green"), guide=FALSE) )
also removes the redundant colour key.



S Ellison



*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}