[R] Transparent backgrounds in png files

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jul 29 09:38:23 CEST 2004


The bitmap() device does not support transparency.  The png() device does.

On Thu, 29 Jul 2004, Patrick Connolly wrote:

> The result I'm aiming to achieve is a bitmap that can be imported into
> a PowerPoint file that shows what's behind the lines of the plot.
> There's a way in PowerPoint that almost works.  By choosing a colour
> to set as transparent, what is behind the graphic is indeed visible,
> but it's at the expense of losing line and text definition.
> 
> I notice there have been discussions about transparent backgrounds
> mostly with lattice plots.  The problem most people seem to have was
> getting a blue background when they wanted a white one.
> 
> Mine is the reverse (and I'm using standard graphics, not Lattice).
> I'm trying to get a transparent background but it always comes out
> white.  Setting bg = "transparent", I've tried using a bitmap device
> to create a png file.  I've also tried creating a postscript file and
> converting it to a PNG file using the Gimp.  I've always used a
> resolution of 300 dpi in bitmaps since the default is far too low.

Really?  You want PNG files of 2000+ pixels in each dimension?  (The
standard size of an R plot is 7", and at 72dpi that is a reasonable size
for on-screen use -- and you should not really be using bitmapped files
for other uses.)

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
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




More information about the R-help mailing list