0

I have the following density plot:

ggplot(...) + aes(x = ..., color = ...) + ggdensity() + 
  labs(color = ...)

However, when i used labs(color = ...), it gives me two legends--one legend with original legend title for fill and another legend with changed title for color. How can i get rid of the original legend created for fill (which I did not specify in the equation)?

  • 1
    Try adding `+ guides(fill = guide_none())` – Allan Cameron Oct 07 '20 at 19:30
  • it worked, what is the reasoning behind using guides function()? why would fill legened not automatically dissapear? – izzy_choco Oct 07 '20 at 19:42
  • 1
    You are using `ggdensity`. I don't even know where that function comes from, but it's not the standard `ggplot` way of making a `geom_density`, so I figured it was some third party function that by default added a fill scale. You didn't want a fill scale, so you need a way of telling `ggplot` to get rid of it. – Allan Cameron Oct 07 '20 at 19:47
  • Does this answer your question? [Turning off some legends in a ggplot](https://stackoverflow.com/questions/14604435/turning-off-some-legends-in-a-ggplot) – Dylan_Gomes Oct 07 '20 at 20:59

0 Answers0