[R] Calling R from a non-X shell script to plot?

doktora v doktora at gmail.com
Mon Dec 13 19:52:56 CET 2004


So, it turns out that using Xvfb is quite simple and works great (fast).

To summ up: if you are trying to plot a png file from a non-X environment, 
run Xvfb, like so (for example):

Xvfb :9 -screen 0 800x600x16&

This will run a virtual X server 9 with screen 0.
In your shell script (or whatever other environment you are using),
set the DISPLAY environment variable to :9.0:
DISPLAY=:9.0
export DISPLAY

presto 
-- dok


On Mon, 13 Dec 2004 13:32:23 -0500, Rajarshi Guha <rxg218 at psu.edu> wrote:
> On Mon, 2004-12-13 at 12:25 -0500, doktora v wrote:
> > I am trying to run R from an apache C++ module in a shell script to
> > plot some data to display it in apache later. I get the error
> > (reported in apache's logs):
> >
> > Xlib: connection to ":0.0" refused by server
> > Xlib: No protocol specified
> > 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`'
> > Execution halted
> 
> I use the following when I need to plot a graphic by calling R from a
> PHP script on my webserver
> 
> bitmap(file=plotfile, height=7, width=7)
> par(pch=19, col='black', cex=1.5)
> plot(log(1/boxsize), log(bv), ylab="log(box count)", xlab="log(1/box
> size)")
> 
> -------------------------------------------------------------------
> Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net>
> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
> -------------------------------------------------------------------
> Science kind of takes the fun out of the portent business.
> -Hobbes
> 
>




More information about the R-help mailing list