First, sorry for posting without reproducible data. Hope you guys understand my question. This is my code. At the end of the code, I am trying to add abline. With the code, I am trying to add the name of abline to the legend but it does not work.
ggplot(aes(x = week_id2, y = Index, color = Chain2, linetype = Chain2, group = Chain2),
data = data00 +
geom_point(aes(shape=Chain2), size = 3) +
geom_line() +
scale_linetype_manual(values=c("twodash", "dashed", "dotted", "dotdash", "longdash")) +
scale_shape_manual(values=c(1:5)) +
xlab("Week") +
ylab("Index") +
geom_hline(aes(yintercept=1))
As shown, I just simply add a name of the abline (let's say the name is "add") in the legend. How should I do it with my current code?
You can add either
color
orlinetype
toaes
then usescale_color_xxx
orscale_linetype_xxx
to fine tune the legend. Here is an example usingeconomics
datasetEdit: per OP's request, we separate
linetype
&color/shape
legendsCreated on 2018-05-08 by the reprex package (v0.2.0).