[R] PNG files and the png function

Prof Brian D Ripley ripley at stats.ox.ac.uk
Thu Aug 3 08:20:19 CEST 2000


On Thu, 3 Aug 2000, Patrick Connolly wrote:

> I can use a postscript device to produce a file which I can open with
> the Gimp, then save quite a good png file.

(Does that not use ghostscript to do the conversion?  If so, you can
do it directly.  As I understood it none of these systems --
xv, ImageMagick. GIMP -- handled postscript directly.)

> If I try to use the png() function directly, I get something rather
> like a graphics screen dump.  The help file doesn't tell me whether it
> should be like that or not.

Yes, it should. What does route 1 give you?  The intention is to produce a
graphics bitmap representing the plot, and that is exactly what the R
screen devices (X11, Windows) show you, so it should be what you want
(if you set the width and height large enough).

You are on Linux, and what png() does there (Windows is similar) is to use
the X11 device to draw on a pixmap, then grab the bitmap from the pixmap
and save in PNG format.

The bitmap() device (and dev2bitmap) uses ghostscript and so ought to be 
similar to the first route.


On my systems I find very little difference between the routes.  The things
I can see differences are in the fonts, where png() uses X11 fonts and
bitmap() gs's Postscript type 1 fonts.  For plots with large numbers (>
256) colours on a system with an 8-bit deep X server bitmap() will produce
better JPEG plots than jpeg(), but PNG will often have problems. (I have
never used an 8-bit deep X server on Linux, but I do on Solaris.) On a 16-
or 24-bit server I get good renditions of the persp examples, for instance.


-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list