Single legend when using group, linetype and colour in ggplot2?

前端 未结 1 1760
礼貌的吻别
礼貌的吻别 2020-12-19 02:57

I am creating a very simple plot that groups data and uses the grouping variable to determine linestyle and colour. I then override those using \'scale_linetype_manaul\' and

相关标签:
1条回答
  • 2020-12-19 03:11

    This might help:

     ggplot(X, aes(x=horizon, y=value, group=TPP, col=TPP, linetype=TPP))+geom_line(size=1)+
      scale_linetype_manual(name="X", values = c("solid","dashed", "dotted"),labels=c("Low", "5","High")) +
      scale_color_manual(name ="X", values = c("black", "red", "blue"),labels=c("Low", "5","High"))
    

    If the labels defined in scale_color_manual and in scale_linetype_manual are different, or if they are specified in only one of them, you will obtain two different legends.

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