In a ggplot density plot, how do I change legend background and fill color of the squares in the legend?
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.