[R] Plotting with Statistics::R, Perl/R

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sat Jan 22 11:59:08 CET 2005


Dirk Eddelbuettel <edd at debian.org> writes:

> a) if you must have png() as a format, you can start a virtual X11 server
>    with the xvfb server -- this is a bit involved, but doable;
>    
> b) if you can do other formats instead of png(), this can work -- I have
>    forgotten the details but the story has been discussed many times over
>    here as web servers use the same "session-less" setup.  In essence,
>    using ghostscript for the bitmap conversion works so it may be that
>    the bitmap() device works.  If I recall pdf(), works.  
>    
> c) With that, you could try creating a pdf() first, and then use Perl to
>    call ghostscript to convert the pdf for you.  R can do that too for
>    you, but only for certain devices.  

d) Use bitmap(). It requires a working Ghostscript install, but is
otherwise much more convenient. Newer versions of Ghostscript have
some quite decent antialiasing built into some of the png devices.
Currently you need a small hack to pass the extra options to
Ghostscript -- we should probably add a gsOptions argument in due
course. This works for me on FC3 (Ghostscript 7.07):

mybitmap(file="foo.png", type="png16m", gsOptions=" -dTextAlphaBits=4
-dGraphicsAlphaBits=4 ")

where mybitmap() is a modified bitmap() that just sticks the options
into the command line. There are definitely better ways...

[The antialiasing is not quite perfect. In particular, the axes stand
out from the box around plots, presumably because an additive model is
used (so that if you draw a line on top of itself, the result becomes
darker). Also, text gets a little muddy at the default 9pt @ 72dpi, so
you probably want to increase the pointsize or the resolution.]

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list