[R] PostScript output error

Mitsuru Oka oka at debian.or.jp
Thu Sep 9 09:41:14 CEST 1999


At Thu, 9 Sep 1999 07:31:20 +0100 (BST),
Prof Brian D Ripley <ripley at stats.ox.ac.uk> wrote:
> 
> On Wed, 8 Sep 1999, Mitsuru Oka wrote:
> 
> > 
> > Hello,
> > 
> > I'm currently using R-0.65.0 with --gnome option in
> > configure on IRIX64 and Debian GNU/Linux.
> > 
> > I found a problem in generated postscript file which
> > has following sequence:
> > 
> >   x <- 1:30
> >   postscript("output.ps")
> >   par(mfg=c(1,1,2,2))
> >   plot(x,sin(x))
> >   plot(x,sin(x))
> >   plot(x,sin(x))
> >   plot(x,sin(x))
> >   dev.off()
> > 
> > The generated postscript file "output.ps" can't be
> > interpreted by Aladdin Ghostscript 5.10.
> > 
> >   Error: /undefined in ps
> >   Operand stack:
> >      (0)   0.5   0.0
> >   Execution stack:
> >      %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   2   3   %oparray_pop   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   --nostringval--   5   3   %oparray_pop
> >   Dictionary stack:
> >      --dict:781/809--   --dict:0/20--   --dict:89/200--
> >   Current allocation mode is local
> >   Current file position is 3092

I added following contexts:

  %%Page: 1 1
  bp                  <- this, (after %%Page..)

and

  /ps 12 def R 12 s   <- this, (before ... t, `t' contain `ps' operator)
  71.56 335.65 (-2) 0.50 0.00 0.00 t

Then, ghostscript interpret modified program right well.


> > What is a problem in my program or R?
> 
> Your R code, primarily.
> 
> I get that error too. But you need
> 
>    x <- 1:30
>    par(mfcol=c(2,2))
>    plot(x,sin(x))
> ....
> 
> As?par says
> 
>      mfg: A numerical vector of the form `c(i, j, nr, nc)'
>           where `i' and `j' indicate which figure in an
>           `nr'-by-`nc' array of figures is currently being
>           drawn.
> 
> and you need to set up the array first, by setting parameter mfrow or
> mfcol.

Thanks, mfcol work right well on my R.

But, I compared mfg with mfcol (file src/main/par.c).
mfcol relate context here:

    else if (streql(what, "mfcol")) {
    int nrow, ncol;
    value = coerceVector(value, INTSXP);
    lengthCheck(what, value, 2);
    posIntCheck(INTEGER(value)[0], what);
    posIntCheck(INTEGER(value)[1], what);
    nrow = INTEGER(value)[0];
    ncol = INTEGER(value)[1];
    dd->gp.numrows = dd->dp.numrows = nrow;
    dd->gp.numcols = dd->dp.numcols = ncol;
    dd->gp.currentFigure = dd->dp.currentFigure = nrow*ncol;
    dd->gp.lastFigure = dd->dp.lastFigure = nrow*ncol;
    dd->gp.defaultFigure = dd->dp.defaultFigure = 1;
    dd->gp.layout = dd->dp.layout = 0;
    if (nrow > 2 || ncol > 2) {
        dd->gp.cexbase = dd->dp.cexbase = 0.5;
        dd->gp.mex = dd->dp.mex = 1.0;
    }
    else if (nrow == 2 && ncol == 2) {
        dd->gp.cexbase = dd->dp.cexbase = 0.8;
        dd->gp.mex = dd->dp.mex = 1.0;
    }
    else {
        dd->gp.cexbase = dd->dp.cexbase = 1.0;
        dd->gp.mex = dd->dp.mex = 1.0;
    }
    dd->dp.mfind = dd->gp.mfind = 1;
    GReset(dd);
    }

and mfg here:

    else if (streql(what, "mfg")) {
    int row, col, nrow, ncol;
    value = coerceVector(value, INTSXP);
    lengthCheck(what, value, 4);
    posIntCheck(INTEGER(value)[0], what);
    posIntCheck(INTEGER(value)[1], what);
    posIntCheck(INTEGER(value)[2], what);
    posIntCheck(INTEGER(value)[3], what);
    row = INTEGER(value)[0];
    col = INTEGER(value)[1];
    nrow = INTEGER(value)[2];
    ncol = INTEGER(value)[3];
    dd->gp.numrows = dd->dp.numrows = nrow;
    dd->gp.numcols = dd->dp.numcols = ncol;
    dd->gp.lastFigure = dd->dp.lastFigure = nrow*ncol;
    dd->dp.mfind = dd->gp.mfind = 1;
    /* currentFigure is 1-based */
    dd->dp.currentFigure = (col-1)*nrow + row;
    /*
      if (dd->dp.currentFigure == 0)
      dd->dp.currentFigure = dd->dp.lastFigure;
    */
    dd->gp.currentFigure = dd->dp.currentFigure;
    dd->gp.defaultFigure = dd->dp.defaultFigure = 1;
    dd->gp.layout = dd->dp.layout = 0;
    dd->gp.new = dd->dp.new = 1;
    if (nrow > 2 || ncol > 2) {
        dd->gp.cexbase = dd->dp.cexbase = 0.5;
        dd->gp.mex = dd->dp.mex = 1.0;
    }
    else if (nrow == 2 && ncol == 2) {
        dd->gp.cexbase = dd->dp.cexbase = 0.8;
        dd->gp.mex = dd->dp.mex = 1.0;
    }
    else {
        dd->gp.cexbase = dd->dp.cexbase = 1.0;
        dd->gp.mex = dd->dp.mex = 1.0;
    }
    GReset(dd);
    }

Both are not so different.
Where is the code to set up array?

--
Mitsuru Oka
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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