[R] generating graphical output when DISPLAY is not set?

Don MacQueen macq at llnl.gov
Wed May 1 00:43:16 CEST 2002

Having asked this question myself within the last 6 months or so, I 
think I can answer.

The R png() driver relies on the png libraries, which come from 
another open-source project, not R. Those libraries require an active 
X11 display. Thus there is no within-R solution for the png() device 
without X11.

There is, however, the bitmap() device (thanks to Prof. Ripley), 
which takes a different approach, and will produce png files without 
X11, provided you have ghostscript installed. In my experience, fonts 
rendered by ghostscript are not as good as fonts with the png(),X11 

Another approach might be to use the Xvfb "device", and see if you 
can't guarantee that it will always be running.


At 1:51 PM -0700 4/30/02, Simon Cawley wrote:
>Is it possible to generate graphical output (to a file) when the
>DISPLAY environment variable is not set?  Here's the problem:
>   $ unset DISPLAY
>   $ R
>   > png("foo.png")
>   Error in X11(paste("png::", filename, sep = ""), width, height, 
>pointsize,  :
>           unable to start device PNG
>   In addition: Warning message:
>   unable to open connection to X11 display`'
>I want to have a process running on a server call R to generate graphical
>output, and the problem is that I'm not guaranteed to have a valid
>DISPLAY set.  I have some clumsy workarounds, but it would be cleaner if
>if I had some way to have R not require the DISPLAY.
>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

Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
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