0
votes

In a ggplot density plot, how do I change legend background and fill color of the squares in the legend?

enter image description here

1

1 Answers

0
votes

Use

theme(legend.key = element_rect(fill = "#F0F0F0"),
      legend.background = element_rect(fill = "#F0F0F0"))

Doing both at once can give the illusion that the square fill is transparent.

enter image description here