MikeZ
MikeZ

Reputation: 355

Opaque Legend Box

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

Answers (2)

Jamie
Jamie

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

timos
timos

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

Related Questions