[R] Graphics output device

Prof Brian D Ripley ripley at stats.ox.ac.uk
Fri Oct 1 08:44:00 CEST 1999

On Fri, 1 Oct 1999, Michael Lapsley wrote:

> Dear developers,
> I wonder would you consider making a save to a graphics file format (as opposed
> to ps)?

You don't tell us the platform you are using, but I guess Unix (because of
xv). Powerpoint only runs on Windows to my knowledge, and the Windows
version of R already has saves to the sort of files Powerpoint likes, for
example Windows metafiles and .gifs.  Because you can use the vector-format
metafiles this avoids multiple rasterization effects. (It would be not at
all easy to do wmf on Unix versions of R.)

R 0.65.1 will have a savePlot function in Windows (and rwtest999 does
already) to effectively select the menu option to do so.

> What prompts this is that we have just finished my wife's thesis using R
> heavily for stats and graphs.  The combination of latex, bibtex and R generated
> .eps worked a treat and we were very pleased with both the final outcome and
> the efficiency of gernerating it, especially when all the graphs were produced
> in batch from scripts.
> The experience of preparing a Powerpoint talk from the same material was much
> less satisfactory, however.  It was positively painful converting eps files
> into png or whatever with scaling difficult to control, and, worst of all, I
> never succeeded in getting the colours to display properly:  white backgrounds
> turned out a peculiar transparent dirty kahki colour. (I think this must be a
> ghostscript bug, but one that I have only ever seen tickled by R).  In the end
> I captured them one at a time with xv and the mouse grab.

You could try re-running the scripts on the Windows version of R.

> Apart from being a real pain I'm mulling over a project that would have
> dynamically generated graphs displayed on a web page:  mouse capture clearly is
> out!  Would saving graphs in pnm or some other convertable format be difficult?
> (Or perhaps there is a package that I have not noticed?)

EPS is highly convertable, I reckon, ghostscript being the prime way to do
so. I have just tried a simple plot and

gs -sDEVICE=pbm -sOutputFile=test.pbm -r150 -q -dNOPAUSE -dBATCH test.ps

and also to png256 and pnm with no problems at all (gs 5.50) and with a
pure white background. Can you report (to R-bugs) an example problem,

Quite a few of my talks (in Acrobat format) have plots that started in R,
were saved as ps, converted to png (to save display time: they have ca 50k
points on, mainly in a few tight clusters) and included by pdftex, and I
have never seen a problem.

Postponing rasterization (those `graphics' formats are actually bitmap
formats) as long as possible is quite desirable, and Acrobat can leave that
until display time. Important when one may not know until arriving on
another continent the resolution of the computer projector until minutes
before the talk.

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