Why won't the ggplot2 legend combine manual fill and scale values?

前端 未结 1 1204
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 20:17

Expected Behavior

If I create a plot with ggplot2 and use separate, say, shape and fill scales to delineate data, I would expect the legend would delineate between \"w

相关标签:
1条回答
  • 2021-02-19 21:12

    You have to override the shape that's being used in the legend, as seen in this question.

    So using your example code (thanks for the clear, reproducible question, by the way), all you need to do is:

    p + guides(fill = guide_legend(override.aes = list(shape = 21)))
    

    Which gives you what you wanted:

    Proper legend

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