[R] png output in batch

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Oct 26 17:15:49 CEST 2000


> Date: Thu, 26 Oct 2000 10:25:51 -0400
> From: Deborah Swayne <dfs at research.att.com>
> To: Prof Brian D Ripley <ripley at stats.ox.ac.uk>
> Cc: Deborah Swayne <dfs at research.att.com>, R help list 
<r-help at stat.math.ethz.ch>
> Subject: Re: [R] png output in batch
> 
> On Thu, Oct 26, 2000 at 07:31:54AM +0100, Prof Brian D Ripley wrote:
> > 
> > There is no way.  png() on Unix depends on having an X server (for the
> > fonts, basically).  I would use bitmap(), which does produce postscript
> > output and convert, but you can control the resolution.
> 
> I can't figure out how to control the resolution and the size
> independently using bitmap().  I'm getting something close
> to what I want with this combination of arguments:
> 
> ps.options(horizontal=F, pointsize=25)
> bitmap ("/usr/dfs/WWW/auction/foo.png", width=2, height=2, res=288)
> 
> In the browser on my laptop, the resulting plot is about 6 inches
> square.  If I drop the resolution to 144, the plot is then about
> 3 inches square.

Ah, but that's your browser setting a resolution for you. All png/bitmap
can do is to create a xx by yy pixel png image.   For Web use I suspect you
want to stick close to the default 72dpi.  For images data there will be
no difference between width=2, res=288 and width-8, res=72.  For
lines and fonts there will be differences in stroke widths and
actual font sizes, and you want the 72dpi version.

If you want a 2" by 2" picture on your laptop, which looks like 100dpi,
do something like.

bitmap ("foo.png", width=2, height=2, res=100, pointsize=3)

and turn the outer margins down or off for so small a plot, e.g.

par(oma=rep(0,4))
plot(1:10)

(You don't need the ps.options, and they will be over-ridden anyway.
You get portrait and a reasonable pointsize unless you set one.)

However, you are going to have problems with lettering on a 2" x 2"
plot, and perhaps it is best to suppress the annotations.

> Any further wisdom for me?  Is there a better approach to using
> cgi for web graphics?  Maybe this just isn't a problem for which
> R or S is the best solution.

I think you can all you need this way. You do need to get the
resolution about equal to the target machine, and ensure that the
details are suppressed as needed.

Brian

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