Opaque box of legends

I was wondering how can I create an opaque box with legends in R for my stories? I tried using bg = "gray", but the lines on the chart still cover the legend.

+5
source share
1 answer

You should use bg = "white" (or any other color as you already did), and you should draw a legend after you build the lines / points / grid, etc.

For instance:

plot(...)
lines(...)
grid(...)
legend(...) # legend has to be the last command!
+11
source

All Articles