I am trying to make the legend key fill for a ggplot transparent. I followed the instructions on one of Hadley\'s ggplot2 guides for changing the legend key fill, but for some
To make use of the transparency levels, one can use:
For the entire legend:
theme(legend.background=element_rect(fill = alpha("white", 0.5)))
alpha("white", 0)
being completely transparent like element_blank()
,
and alpha("white", 1)
having no transparency.
Now, for the key - if key and background have different transparencies:
theme(legend.background=element_rect(fill = alpha("white", 0)),
legend.key=element_rect(fill = alpha("white", .5)))
Note: background transparency overrules the one for the key, i.e. background alpha must be smaller than key alpha.