I have looked around in the documentation and posts like this, but it is not clear to me. Apparantly a legend is created automatically and I have to map colors to explaining text.
An example with data:
vtm1<- c(1,3,4)
vmean<-c(3.9,3.8,3)
vmax<-c(4.1,4.2,4)
vmin<-c(3,2.5,2)
rtm1<- c(1,2,4,5)
rmean<-c(3.9,3.85,3.7,3.1)
rmax<-c(4.1,4.2,4,3.9)
rmin<-c(3,2.5,2,1.9)
gtm1<- c(2,4,5)
gmean<-c(4.1,3.9,3)
gmax<-c(4.1,4,3.9)
gmin<-c(3,2.5,1.5)
vns <- data.frame(vtm1, vmean, vmax, vmin)
gibbs <- data.frame(gtm1, gmean, gmax, gmin)
rw <- data.frame(rtm1, rmean, rmax, rmin)
plt <- ggplot(NULL, aes(x= vtm1))
plt + xlab("Number of TM lookups") + ylab("Cross-entropy") +
xlim(0, 30000000) +
ylim(3.15,4.2)+
geom_ribbon(data=gibbs, aes(x = gtm1, ymin= gmin, ymax= gmax), fill="#A8A8A8") +
geom_ribbon(data=rw, alpha=0.5, aes(x = rtm1, ymin= rmin, ymax= rmax), fill="red")+
geom_ribbon(data=vns, alpha=0.5, aes(x = vtm1, ymin= vmin, ymax= vmax), fill="mycolor")+
geom_line(data=gibbs, linetype = "dotdash", aes(x=gtm1,y=gmean)) +
geom_line(data=vns,aes(x=vtm1,y=vmean)) + geom_line(data=rw, linetype = "dashed", aes(x=rtm1,y=rmean)) +
geom_hline(yintercept=3.2240952381, linetype = "dotted", color="mycolor2")+
geom_hline(yintercept=3.44366666666667, linetype = "dotted") +
theme_bw( )+
scale_colour_manual(name="Lines", values=c("mycolor"="blue","mycolor2"="red")) +
scale_linetype_manual(name="Lines", values=c("mycolor"="dotted","mycolor2"="dashed"))
R keeps giving me the error:
Error in col2rgb(colour, TRUE) : invalid color name 'mycolor'