Possible Duplicate:
ggplot2 add a legend for several stat_functions
I'm trying to superimpose 3 functions (using stat_function
) on top of a scatterplot (geom_point
), and add a legend for the superimposed functions. I've successfully produced a plot with the functions, but I'm not sure how to add the legend.
ggplot(questionnaire,aes(A,B)) +
geom_point() +
stat_function(...,colour="blue") +
stat_function(...,colour="red") +
stat_function(...colour="green")
Any help with how to add a legend that explains what each of the different colored lines is would be appreciated.