[R] Q: obtaining non-transparent background in png

James W. MacDonald jmacdon at med.umich.edu
Tue Jul 31 18:58:27 CEST 2007


Both of these work for me:

par(bg="red")
plot(1:10)
dev.print(png, width=800, height=600, filename="tmp.png")

and

png("tmp.png", width=800, height=600, bg="red")
plot(1:10)
dev.off()

Best,

Jim



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.
> 
> 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 at 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.

-- 
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623



More information about the R-help mailing list