In ggplot, how can I add a legend entry for each of the geom_function
s so that the color and linetype are displayed (e.g for fun1
a short dotted red line), along with a custom name that I choose?
ggplot(data = data.frame(x = seq(0, 1, by=0.01)), mapping = aes(x=x)) +
geom_function(fun = fun1, linetype='11', color='red') +
geom_function(fun = fun2, color='dark green') +
geom_function(fun = fun3, linetype='dashed', color='blue')