How do I use ggplot2
with stat_summary
to show colours of my choice? Eg.:
simVol <- data.frame(simId=c(1,1,1,1,2,2,2,2),
farm=rep(c('farm A', 'farm A', 'farm B', 'farm B'),2),
period=rep(1:2,4),
volume=c(9,21,12,18,10,22,11,19))
P10meanP90 <- function(x) data.frame(
y = mean(x),
ymin = quantile(x, .1),
ymax = quantile(x, .9)
)
This command plots the distribution of volume at each farm against the period, using default colours:
ggplot(simVol, aes(x=period, y=volume, colour=farm)) +
stat_summary(fun.data="P10meanP90", geom="smooth", size=2)
However, if I add colour='green'
to the arguments of stat_summary
, it plots instead the aggregate across farms. I've tried using colour=c('green','orange')
, but this still only shows a green line.
How do I change the colours in this plot?
thanks