I have found seemingly correct solutions to my problem of creating a mixed legends with linetype and colour here and here. However my code still does not the expected and instead produces a legend where the linetype is not taken into account. My goal is to have my legend match my plot.
I have started with a simple scale_linetype_manual("",value = c(2,2,1,1,1))
and stopped at the attempt in the code below.
ggplot(data_norm_long, aes(x = as.integer(year), y = value, colour = variable, linetype = kat), group = "variable") +
geom_point() +
geom_line() +
scale_color_manual("",
breaks = c("LO_kat2","lean_kat2","hola_kat1","lean_kat1","LO_kat1"),
values = c(LO_kat2 = "darkblue", lean_kat2 = "darkgreen", hola_kat1 = "darkred", lean_kat1 = "darkgreen", LO_kat1 = "darkblue"),
labels = c("Label 1","Label 2","Label 3","Label 4","Label 5")) +
scale_linetype_manual("",
breaks = c("LO_kat2","lean_kat2","hola_kat1","lean_kat1","LO_kat1"),
values = c("1" = "solid", "2" = "dashed"))
Plot:
Current plot (Apparently I'm not allowed to embed images.)