I'm trying to use R in a cgi script to produce graphics files in png format, and I'm having a problem. My shell command line looks like this: R </usr/dfs/auction/eligibility.R --no-save >/tmp/R.out and the line in the R script looks like this: png ("foo.png", pointsize=18) If I run outside the cgi context, it runs great. When run as in a cgi script, I get this error message: Error in X11(paste("png::", filename, sep = ""), width, height, pointsize, : unable to start device PNG Is there any way to trick this command into doing what I want? I can alternatively produce postscript output, and then convert to png, but I find the resolution disappointing. (I'm using unix.) Debby -- Deborah Swayne AT&T Labs - Research dfs at research.att.com Shannon Laboratory, Room B295 www.research.att.com/~dfs 180 Park Avenue 973 360-8423 Florham Park, NJ 07932-0971 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Deborah Swayne wrote:> > I'm trying to use R in a cgi script to produce graphics > files in png format, and I'm having a problem. > > My shell command line looks like this: > R </usr/dfs/auction/eligibility.R --no-save >/tmp/R.out > and the line in the R script looks like this: > png ("foo.png", pointsize=18) > > If I run outside the cgi context, it runs great. When > run as in a cgi script, I get this error message: > > Error in X11(paste("png::", filename, sep = ""), width, height, pointsize, : > unable to start device PNG > > Is there any way to trick this command into doing what I want? > > I can alternatively produce postscript output, and then > convert to png, but I find the resolution disappointing. > > (I'm using unix.) > > DebbyI think bitmap() is a better solution. It also produces png-files. Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 25 Oct 2000, Deborah Swayne wrote:> I'm trying to use R in a cgi script to produce graphics > files in png format, and I'm having a problem. > > My shell command line looks like this: > R </usr/dfs/auction/eligibility.R --no-save >/tmp/R.out > and the line in the R script looks like this: > png ("foo.png", pointsize=18) > > If I run outside the cgi context, it runs great. When > run as in a cgi script, I get this error message: > > Error in X11(paste("png::", filename, sep = ""), width, height, pointsize, : > unable to start device PNG > > Is there any way to trick this command into doing what I want? > > I can alternatively produce postscript output, and then > convert to png, but I find the resolution disappointing. > > (I'm using unix.)There is no way. png() on Unix depends on having an X server (for the fonts, basically). I would use bitmap(), which does produce postscript output and convert, but you can control the resolution. (I would use it even in interactive use.) -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Deborah Swayne <dfs at research.att.com> writes:> I can alternatively produce postscript output, and then > convert to png, but I find the resolution disappointing.How are you doing the conversion? Postscript should be renderable to PNG at arbitrary resolutions (and is usually smaller). At the moment, Rcgi uses postscript as an intermediate step before rendering to GIF. But anyway, as was also said, bitmap() is probably a good first thing to look at. I'm about to restart work on Rcgi to bring it up-to-date for R 1.1+ and would like to announce that on a R list. Do I have to ask anyone's permission? -- MJR (Not an official statement) Please note changes of address http://stats.mth.uea.ac.uk/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Date: Thu, 26 Oct 2000 10:25:51 -0400 > From: Deborah Swayne <dfs at research.att.com> > To: Prof Brian D Ripley <ripley at stats.ox.ac.uk> > Cc: Deborah Swayne <dfs at research.att.com>, R help list<r-help at stat.math.ethz.ch>> Subject: Re: [R] png output in batch > > On Thu, Oct 26, 2000 at 07:31:54AM +0100, Prof Brian D Ripley wrote: > > > > There is no way. png() on Unix depends on having an X server (for the > > fonts, basically). I would use bitmap(), which does produce postscript > > output and convert, but you can control the resolution. > > I can't figure out how to control the resolution and the size > independently using bitmap(). I'm getting something close > to what I want with this combination of arguments: > > ps.options(horizontal=F, pointsize=25) > bitmap ("/usr/dfs/WWW/auction/foo.png", width=2, height=2, res=288) > > In the browser on my laptop, the resulting plot is about 6 inches > square. If I drop the resolution to 144, the plot is then about > 3 inches square.Ah, but that's your browser setting a resolution for you. All png/bitmap can do is to create a xx by yy pixel png image. For Web use I suspect you want to stick close to the default 72dpi. For images data there will be no difference between width=2, res=288 and width-8, res=72. For lines and fonts there will be differences in stroke widths and actual font sizes, and you want the 72dpi version. If you want a 2" by 2" picture on your laptop, which looks like 100dpi, do something like. bitmap ("foo.png", width=2, height=2, res=100, pointsize=3) and turn the outer margins down or off for so small a plot, e.g. par(oma=rep(0,4)) plot(1:10) (You don't need the ps.options, and they will be over-ridden anyway. You get portrait and a reasonable pointsize unless you set one.) However, you are going to have problems with lettering on a 2" x 2" plot, and perhaps it is best to suppress the annotations.> Any further wisdom for me? Is there a better approach to using > cgi for web graphics? Maybe this just isn't a problem for which > R or S is the best solution.I think you can all you need this way. You do need to get the resolution about equal to the target machine, and ensure that the details are suppressed as needed. Brian -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._