On Fri, Jan 21, 2005 at 06:06:45PM -0800, Leah Barrera wrote: > I am trying to plot in R from a perl script using the Statistics::R > package as my bridge. The following are the conditions: > > 0. I am running from a Linux server. > > 1. Even without xwindows the following saves test.png correctly from an > interactive session with R: > > xy<-cbind(1,1) > > png("test.png") > > plot(xy) > > dev.off() > > 2. However, when called from the perl script I get the ff. warning: > -- > X11 module is not available under this GUI > -- > and nothing is saved > > 3. I tried to hijack the script by modifying > lib/Statistics/R/Bridge/Linux.pm to remove the > "gui=none" setting > -- > $this->{START_CMD} = "$this->{R_BIN} --slave --vanilla --gui=none" ; > -- > changed to > -- > $this->{START_CMD} = "$this->{R_BIN} --slave --vanilla" ; > -- > > 4. When plotting in R from the perl script again, I no longer get the > warning and I get test.png saved, but it is empty. > > Please advise.
It's a FAQ. 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; 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. Hth, Dirk -- Better to have an approximate answer to the right question than a precise answer to the wrong question. -- John Tukey as quoted by John Chambers ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html