I'm having a problem with making dashed lines appear in the legend. couldn't make "scale_linetype_manual" work.
Thanks.
years = mydata$g2_year
ggplot(data=mydata, aes(x=years))+
geom_line(mapping=aes(y=g1_center, color="Centre"), size=1.5) +
stat_smooth(aes(y = g1_center, color = "Poly.(Centre)"),method = "lm", formula = y ~ x + I(x^2), size = 1,se = FALSE, linetype = "dashed") +
geom_line(mapping=aes(y=g1_periphery, color="Periphery"),size=1.5)+
stat_smooth(aes(y = g1_periphery, color = "Poly.(Periphery)"),method = "lm", formula = y ~ x + I(x^2), size = 1,se = FALSE, linetype = "dashed") +
scale_x_continuous("", labels = as.character(years), breaks = years)+
scale_y_continuous("", breaks = c(-5:5))+
theme_light()+
theme(axis.text.x = element_text(angle = 90, vjust=0.5), legend.position="top", text = element_text(size = 11),
legend.key.size = unit(0.5, "in")) +
scale_color_manual(name="",values=c("#E69F00","#56B4E9", "#E69F00","#56B4E9"))+
scale_linetype_manual(values = c(1, 1, 2, 2))