[R] Postscript Legends (or not)

Jim Lemon bitwrit at ozemail.com.au
Fri Jun 23 11:30:38 CEST 2000


Anon wrote:

...However, if I use Fred <- c(1,"33")...
Is this a bug, or am I missing something?

This is an interesting problem.  It boils down to the fact that
PostScript expects an array (even if it's empty) and an offset for
"setdash".  Normally, a solid line is specified with an empty array and
zero offset.  However, if R gets specs that convert to zero and puts a
zero in the array, the PostScript interpreter will barf.  Zero can
appear, but there must be at least one non-zero number in the array.
Hexadecimal strings supplied to lty are converted to array elements, but
a single character "1" seems to produce "0.00".  Remember that the c()
operater will coerce the number 1 to the string "1" when combining it
with "33".  That is, it's probably a bad idea to mix the two methods of
specifying line types with "lty".

A possible fix is to insert a test for zero in the function
SetLineStyle() - devPS.c:

static void SetLineStyle(int newlty, double newlwd, DevDesc *dd)
{
    PostScriptDesc *pd = (PostScriptDesc *) dd->deviceSpecific;
    int i, ltyarray[8];
    int sum = 0;
    if (pd->lty != newlty || pd->lwd != newlwd) {
      pd->lwd = newlwd;
      pd->lty = newlty;
      PostScriptSetLineWidth(pd->psfp, dd->gp.lwd*0.75);
      for(i = 0; i < 8 && newlty & 15 ; i++) {
          ltyarray[i] = newlty & 15;
          sum += ltyarray[i];
          newlty = newlty >> 4;
      }
      if(!sum) i = 0;
      PostScriptSetLineTexture(pd->psfp, ltyarray, i, dd->gp.lwd *
0.75);
    }
}

producing a solid line when all elements of 'ltyarray' are zero.

Jim


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