ggplot2: how to remove slash from geom_density legend

后端 未结 1 1570
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 07:36

I\'m trying to plot some overlapping density plots in ggplot2. I\'m running into a problem where I cannot remove the diagonal slash from the legend. I have tried using scale

相关标签:
1条回答
  • 2020-12-14 08:22

    Try this:

    + guides(fill = guide_legend(override.aes = list(colour = NULL)))
    

    although that removes the black outline as well...which can be added back in by change the theme to:

    legend.key = element_rect(colour = "black")
    

    I completely forgot to add this important note: do not specify aesthetics via x=iris$Sepal.Length using the $ operator! That is not the intended way to use aes() and it will lead to errors and unexpected problems down the road.

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