Bug 14843 - dev.print treats background inconsistently
Summary: dev.print treats background inconsistently
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: R 2.14.1 patched
Hardware: All All
: P5 minor
Assignee: R-core
Depends on:
Reported: 2012-03-13 14:59 UTC by Fang
Modified: 2012-03-13 14:59 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Fang 2012-03-13 14:59:21 UTC
As per http://tolstoy.newcastle.edu.au/R/e2/help/07/08/22409.html and current ?dev.print, dev.print supposedly forces the output to have the same background as the displayed plot, effectively ignoring the 'bg' param supplied to the device.

However, in practice, the behaviour is inconsistent:

#both produce a transparent plot:
dev.print(pdf, "test.pdf", bg  = "red")
dev.print(png, "test.png", bg  = "red", width = 500)
#produces a red plot!
dev.print(jpeg, "test.jpg", bg = "red", width = 500)
dev.print(bmp, "test.bmp", bg = "red", width = 500)
dev.print(tiff, "test.tiff", bg = "red", width = 500)

One view is that the behaviour of jpeg, bmp and tiff are a bug, and they should be brought into line with pdf and png and straightforwardly reject the 'bg' parameter.

Alternatively, I would suggest that allowing the 'bg' option to override the background setting is an useful feature, and would be for most users the expected behaviour if bg is set. 

Otherwise the alternative options for users who want non-transparent png versions of plotted images is to either have the foresight to set bg="white" before plotting, or to open a new device with png() and replot from scratch: an approach with the disadvantage of having to repeat any computational processing that has been done, and preventing them from interactively setting the aspect ratio by resizing the window. Clearly the jpeg-like 'bg' behaviour is in principle possible.