I am trying to add a legend to the following combined ggplot. I have tried many times, but it looks like I won't succeed.
The legend should have 'Years' as title and than the years 1995 (which is green), 1996 (which is red) and 2000 (which is blue) with the combined colour of the line and the shape of the points.
Any help is welcome.
Thank you in advance!
####
library("ggplot2")
library("grid")
library("gridExtra")
#####
#####
breaks.major <- c(105,135,165,195,225,255)
breaks.minor <- c(90,120,150,180,210,240,270)
labels.minor <- c("Apr","May","June","July","Aug","Sept")
lims =c(90,270)
######
ggplot() +
# Green plot
geom_point(data=MeanL_1995, aes(x=SamDay, y=TL_mm), shape=15, colour="green", size=2.5)+
geom_line(data=MeanL_1995, aes(x=SamDay, y=TL_mm), shape=15, colour="green", size=0.5)+
# Red plot
geom_point(data=MeanL_1996, aes(x=SamDay, y=TL_mm), shape=16, color="red", size=2.5)+
geom_line(data=MeanL_1996, aes(x=SamDay, y=TL_mm), shape=16, color="red", size=0.5)+
# Blue plot
geom_point(data=MeanL_2000, aes(x=SamDay, y=TL_mm), shape=17, color="blue", size=2.5)+
geom_line(data=MeanL_2000, aes(x=SamDay, y=TL_mm), shape=17, color="blue", size=0.5)+
scale_x_continuous(limit = lims, minor_breaks = breaks.minor, breaks = breaks.major, labels = labels.minor)+
ylab("Mean length (mm)")+
xlab("")+
guides(colour = guide_legend(title="Years", shape = guide_legend(title="Years")))