Reputation: 355
I was wondering how I could go about creating an opaque legend box in R for my plots? I've tried using bg="grey", but the lines on the graph are still covering the legend.
Upvotes: 6
Views: 4065
Reputation: 782
I know this is an old question but there is another way to do this than has been presented thus far.
Just use the following statement when creating your legend:
bg=make.transparent("red",0.8)
Upvotes: 0
Reputation: 2707
You have to use bg="white" (or any other color, as you already did) and you have to draw the legend after you plot the lines/points/grid/etc.
For example:
plot(...)
lines(...)
grid(...)
legend(...) # legend has to be the last command!
Upvotes: 11