Hello,
consider the following example:
dat <- data.frame(x = c(1:5,1:5), y = c(1:5,c(2,4,6,8,10)))
g.lines <- data.frame(slope = c(1,2),intercept= rep(0,2),group = factor(1:2))
ggplot() + geom_point(data=dat,aes(x=x,y=y)) +
geom_abline(data=g.lines,aes(slope=slope,intercept=intercept,linetype=group))
I would like the plot to create a legend for linetype within geom_abline. But I cannot get it to work. I have tried scale_linetype_manual, but this does not work either.