I am pretty new to R so please excuse me if I got this wrong.
I am trying to change a dashed linetype of a geom_hline
in ggplot2 to a solid one.
Any help is much appreciated!
Usually this is easily done with changing linetype = "dashed"
to linetype = "solid"
. But since I have to use linetype for the text in my legend I cannot do this. Also adding linetype = "solid"
after color results in
Error in [[<-.data.frame (tmp, i, value = c("blue", "blue")) : Replacement has 2 lines, Data has 1`
This is the code that I am trying to adjust:
geom_hline(aes(yintercept = 5, linetype = "Title 1"), colour = "blue") +
geom_hline(aes(yintercept = 2, linetype = "Title 2"), colour = "blue") +
scale_linetype_manual(name = "", values = c(2, 2),
guide = guide_legend(override.aes = list(color = c("blue", "blue"))))