You are *copying* the plot, and that means copying the background too (it *is* part of the plot). Almost certainly the plot you are copying had a transparent background: that is the default for X11.
All the confusion seems to be over misreadings of this. On Tue, 31 Jul 2007, Gavin Simpson wrote: > On Tue, 2007-07-31 at 10:22 -0600, D. R. Evans wrote: >> I am not understanding something about generating PNG plots. >> >> I have tried several ways to obtain something other than a transparent >> background, but nothing I've done seems to change the background. >> >> For example: >> >> dev.print(png, width=800, height=600, bg='red', filename='example.png') >> >> which I thought would give a red background, simply gives the same >> transparent background I always get. > > ?dev.print says: > > 'dev.print' copies the graphics contents of the current device to > a new device which has been created by the function specified by > 'device' and then shuts the new device. > > Note "copies" - given that you've already drawn a figure with a white > background, should this then produce one that is red? However, you are > correct that it does produce a plot with a transparent background. > > I find it easier to wrap my plotting commands in the relevant device, > e.g. this works with the desired background: > >> png("mypng.png", height = 400, width = 400, bg = "red", > pointsize = 12) >> plot(1:10) >> dev.off() > > Whereas these do not give "red" backgrounds as one might have expected, > but transparent ones: > >> plot(1:10) >> dev.print(png, height = 400, width = 400, bg = "red", pointsize = 12, > filename = "mypng2.png") > X11 > 2 >> dev.copy(png, height = 400, width = 400, bg = "red", pointsize = 12, > filename = "mypng3.png") > PNG > 3 >> dev.off() > X11 > 2 > > Not sure whether this is as intentional or not, but it does not appear > to be passing the bg argument on to the 'device', or if it does, it is > not being used/respected - perhaps all that is need is clarification as > to what can be specified in '...' in ?dev.print > >> version > _ > platform i686-pc-linux-gnu > arch i686 > os linux-gnu > system i686, linux-gnu > status Patched > major 2 > minor 5.1 > year 2007 > month 07 > day 05 > svn rev 42131 > language R > version.string R version 2.5.1 Patched (2007-07-05 r42131) > > G > >> >> And I also don't understand why the default background is transparent, >> when the documentation seems to say that it's white: >> png(filename = "Rplot%03d.png", width = 480, height = 480, >> pointsize = 12, bg = "white", res = NA,...) >> >> (This is on a Kubuntu dapper 64-bit system.) >> >> [I looked through the mail archives, and there seem to be a few very >> old postings talking about the opposite problem, but nothing recent; >> so I conclude that I'm doing something wrong.] >> >> ______________________________________________ >> R-help@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.