Dear All,
I am trying to add manually a legend to a plot, tried to follow examples on forums but I am still missing something.
Any help on the issue is greatly appreciated!
Ale
dati: data.frame
Year: years from 1975 to 2011
Births: number of births
Age_Group: age groups from 1 to 7
p <- ggplot(dati, aes(Year,Births1))
p + geom_line(data=dati[which(dati$Age_Group=="1"),],colour = "red", size = 1) +
geom_line(data=dati[which(spain.agegroup$Age_Group=="2"),],colour = "lightblue", size = 1) +
geom_line(data=dati[which(spain.agegroup$Age_Group=="3"),],colour = "green", size = 1) +
scale_y_continuous(breaks=c(0,25,50,75,100,125,150,175))+
scale_x_continuous(breaks=c(1975,1980,1985,1990,1995,2000,2005,2011),limits=c(1974,2012))+
theme(axis.line=element_line(color="black"),
axis.text= element_text(colour="black", size=20, angle=0,face = "plain"),
panel.background=element_rect(fill="white"),
panel.grid=element_line(colour="grey"),
axis.text.x = element_text(hjust=.5, vjust=.5),
axis.text.y = element_text(hjust=1, vjust=0),
strip.text.x = element_text(size = 8, colour =
"black", angle = 0),
plot.title= element_text(size=20))+
#my line for legend...
scale_colour_manual(name="Age Groups",values=c("15-19"="red","20-24"="lightblue","25-29"="green","30-34"="darkorange","35-39"="brown","40-44"="darkblue","45-49"="violet"))
Alessandra Carioli
NIDI and University of Groningen
Langehoutstraat 19
2511 CV
+31(0)70-3565259
car...@nidi.nl