0

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"))))
teunbrand
  • 33,645
  • 4
  • 37
  • 63
Tassio
  • 1
  • 3
    Please provide a reproducible working example with your entire `ggplot` call and data, see https://stackoverflow.com/a/5963610/882102 – MrGumble Aug 01 '19 at 09:18
  • Have you tried `scale_linetype_manuaL(name = "", values = c(1,1), ...)` ? – teunbrand Aug 01 '19 at 09:44
  • What do you mean with Have you tried 'scale_linetype_manuaL(name = "", values = c(1,1), ...)' ? That's what I am using! – Tassio Aug 01 '19 at 10:06
  • This is the plot I am using 'ggplot(data,aes(one, two, color = high)) + geom_point(shape=19, size = 5, alpha=0.8, position=position_jitter(width=.1,height=.01)) + jitter scale_x_continuous(breaks=c(1, 2, 3, 4, 5, 6))' – Tassio Aug 01 '19 at 10:08

0 Answers0