Opaque legend on R chart with transparent background?

I am trying to put a legend in an R plot, on top of some grid lines. I want the legend to be opaque so that the gridlines are not drawn over the legend. However, I also want the entire image to have a transparent (not white) background for display on the web.

I know what I can do bg="white"

to get an opaque legend, but it doesn't match with png(..., bg=transparent)

. Example:

    png("test.png", bg="transparent")
    plot(rnorm(10))
    grid()
    legend("topright", legend="foo", bg="white")
    dev.off()

      

When this png is displayed on a website with a colored background, the color will appear on most of the graph, but the legend will still be white. Is there a way to make the legend "opaque" so that the gridlines don't show up but are still transparent in the final png output?

+3
r transparency plot png legend


source to share


No one has answered this question yet

Check out similar questions:

979
Hexagonal transparency in colors
765
How to remove a legend from a plot
561
How to make the background 20% transparent on Android
52
How to export plots from matplotlib with transparent background?
50
Setting the background of transparent images in IrfanView
35
story legends without borders and with a white background
nine
problem with saving R-graph with transparent background
7
ggplot2 make the vowel key fill transparent
2
How to fill the background color of a legend when printing with two axes?
0
How to "send to the front" a legend with matplotlib?



All Articles
Loading...
X
Show
Funny
Dev
Pics