Open MichaelChirico opened 4 years ago
Workaround: stating the bg argument directly in the graphics device to transparent seems to work for all devices:
png('test.png', bg='transparent'); plot(1:10); dev.off() svg('test.svg', bg='transparent'); plot(1:10); dev.off()
As far as I understand setting par(bg='transparent') should (but does not) work for png as well as for svg.
Best
This is reproducible in R 3.6.2.
When opening the svg device with default bg="white" and then modifying the background via par(bg='transparent') it still adds
to the svg file, i.e. a white rectangle. Similary, if we open the device with svg(..., bg="blue") and then set par(bg="transparent") we still get a blue rectangle with rgb(0%,0%,100%). Thus, setting par(bg="transparent") seems to have no effect on the svg device.
In contrast, when opening the svg device with an initially transparent background via svg(..., bg='transparent') no
Interestingly, the svglite device provided by the svglite package has the same problem. Setting par(bg="transparent") after opening the graphics device has no effect.
Created attachment 1607 [details] test.svg with white background instead of expected transparent background
Setting background to transparent via par(bg='transparent') seems to not trigger a transparent background of svg devices, although it works for other colors with svg devices and for other devices with transparent.
How to reproduce:
# works fine png('test.png'); par(bg='transparent'); plot(1:10); dev.off()
# works fine too svg('test.svg'); par(bg='blue'); plot(1:10); dev.off()
# white background added? svg('test.svg'); par(bg='transparent'); plot(1:10); dev.off()
METADATA