Duplicate legend with geom_vline() in ggplot

前端 未结 1 787
春和景丽
春和景丽 2021-01-22 23:16

I want to create this graphic:

aux_graf = structure(list(lines = structure(c(2L, 2L, 1L, 3L), .Label = c(\"h0\", 
\"ic\", \"median\"), class = \"factor\"), value         


        
相关标签:
1条回答
  • 2021-01-23 00:18

    You can use override.aes in combination with hiding the linetype legend. With:

    gp2 + 
      scale_color_manual(name = '', 
                         labels = c(ic = 'Limites I.C.', median = 'Mediana', h0 = 'Hipotese Nula'),
                         values = c(ic = 'red', median = 'black',h0 = 'grey40')) +
      guides(color = guide_legend(override.aes = list(linetype = c('dotted', 'dashed', 'solid'))),
             linetype = FALSE)
    

    you will get this: enter image description here

    0 讨论(0)
提交回复
热议问题