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

Tim Churches tchur at optushome.com.au
Sat Jan 22 04:52:40 CET 2005


Dirk Eddelbuettel wrote:

>Plotting certain formats requires the X11 server to be present as the font
>metrics for those formats can be supplied only the X11 server. Other drivers
>don;t the font metrics from X11 -- I think pdf is a good counterexample.
>When you run in 'batch' via a Perl script, you don't have the X11 server --
>even though it may be on the machine and running, it is not associated with
>the particular session running your Perl job.  There are two common fixes:
>
>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;
>  
>
An example of a Python programme which manages the starting of an Xvfb 
server when one is required can be found in the xvfb_spawn.py file 
/SOOMv0 directory of the tarball for NetEpi Analysis, which can be 
downloaded by following the links at http://www.netepi.org

xvfb_spawn.py was written for use with RPy, which is a Python-to-R 
bridge, when used in a Web server setting (hence no X11 display server 
available). It should be possible to translate the programme to Perl, or 
to write somethig similar in Perl. Comments in the code note some 
potential security traps for the unwary.

Hopefully one day the dependency of the R raster graphics devices on an 
X11 server will be removed. R on Win32 doesn't have that dependency (but 
then, Windows machines, even servers, have displays running all the time 
as part of their kernel, and who would wish that on other operating 
system?). However, there are several graphics back-ends which produce 
very high quality raster graphics on POSIX platforms without the need 
for an X11 device to be present - Agg ("Anti-grain geometry", see 
http://www.antigrain.com/) and Cairo (see http://cairographics.org/) 
spring to mind (usually disclaimers about the foregoing comments not 
meaning to seem like ingratitude to the R development team etc apply).

Tim C




More information about the R-help mailing list