[R] Transparent backgrounds in png files
MSchwartz at MedAnalytics.com
Fri Jul 30 05:34:32 CEST 2004
On Thu, 2004-07-29 at 19:24, Patrick Connolly wrote:
> On Thu, 29-Jul-2004 at 08:38AM +0100, Prof Brian Ripley wrote:
> |> The bitmap() device does not support transparency. The png() device does.
> Unfortunately, though png() does a fine job at a transparent
> background, it's rather lumpy even on a screen.
> |> On Thu, 29 Jul 2004, Patrick Connolly wrote:
> |> > 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?
> Well, 300 dpi is somewhat excessive for onscreen, but not for printing
> (more below). For a screen at 1600 by 1200 resolution, a bitmap of
> over 1000 pixels in either direction is not excessive. Using a screen
> rated at .25mm dot pitch, 75dpi is rather a lot less than sufficient.
> According to my calculations, .25mm dot pitch corresponds to over 100
> dpi, and a .27mm screen is over 90 dpi, so I don't get this 72
> business. Perhaps there's something I need to know.
> Evidently, there's something others know that I don't since png()
> generated files always turn out lumpy for me. It's worse than the
> unsatisfactory result of using PowerPoint's turning colours to
> transparent method I mentioned. People who are used to looking at TV
> screens might not think it's low resolution, so perhaps I'm too fussy.
> Maybe I should be more fussy about getting an exact ratio between the
> number of pixels in the plotting device and the size of the image in
> PowerPoint. I'm somewhat confused by the fact that PP scales to fit
> to the slide PNG files that I produce using the Gimp, but not ones
> made using the png() method directly. What is the essential
> |> -- and you should not really be using bitmapped files for other
> |> uses.)
> Unfortunate as it may be, many people wish to put graphics in Word
> files and don't like being unable to see their graphics on their
> screen even if they have a postscript printer that could print them
> perfectly. That's where I use 300 dpi PNGs which print at least as
> well as WMFs I've seen.
> There was a recent discussion on this list about graphics using OSX
> which covers most of the same thinking. Nothing in that discussion
> indicated to me a better way to get graphic files from Linux to Word.
> If there are any, I'd like to know about them.
Are the Windows recipients of the R graphics involved in
creating/editing the resultant documents, or do they simply require
"read only" access of a final document?
If the latter, then let me suggest that you generate EPS based graphics
in R (for which you can specify height and width arguments in inches as
required). Import those EPS graphics into OO.org's Impress (PP-alike) or
Writer (Word-alike). Then print the file to a PS file and then use
ps2pdf to create a PDF version of the document that the recipients can
view in Acrobat Reader.
If the former, as I believe Frank Harrell noted here some time back, the
recent versions of Word and Powerpoint will create bitmapped previews of
the EPS files upon import. While they are not a high quality image (and
do add to filesize notably), they at least enable the users of the
documents to preview the image for placement/sequencing. They can then
print them to a PS file or if they have the purchased Adobe add-ins,
could print them to a PDF file on their own for viewing in Acrobat.
The major problem with bitmapped images (as has been mentioned here ad
nauseum) is that they do not resize well and what you see on the screen
does not always translate into a quality image when enlarged or sent to
a printer. This is why vector based graphics (such as WMF/EMF, EPS, PDF
and SVG) are preferred. Bitmapped image files also end up being quite
large, whereas EPS files (since they are text files) are relatively
It is not a solution today, but as SVG based graphics become more
available on multiple platforms, that format will probably emerge as the
preferred means of sharing such files. WMF/EMF are limited to Windows as
a realistic option. There is the libEMF library available under Linux,
but from personal experience, it is not a viable option.
More information about the R-help