[R] margins with postscript device

Trent Piepho xyzzy at speakeasy.org
Sat Jul 1 02:02:59 CEST 2000


I've been having a problem when printing plots to a HP DeskJet 2500C printer. 
This printer, like most inkjet printers, has a large minimum bottom margin. 
For most HP inkjet printers, the bottom 1/2" (left 1/2" inch for landscape)
of the page can't be printed too.  The postscript device in R has a default of
1/4" margins between the paper edge and the plotting area.  This means that
bottom (or left in landscape) 1/4" inch of the plotting area is cut off. 
Typically, the Y-axis label in landscape plots will be cut off.

I couldn't find any good way to fix this using the postscript device options,
as there is no way to set the margins.  The closest thing would be to set the
paper width or height to 1" less than the paper size, giving a 1/2" margin on
both sides.  This means I have to figure out if I'm doing a landscape or
portrait plot, find the size of the paper I'm using, and subtract double the
size of the largest margin I want.  This also forces both the top and bottom
margins to be the same, when I would rather have a 1/2" bottom margin and only
a 1/8" top margin (the printer's minimum for the top), so I don't lose so much
of the paper's space.

I think it would be useful if the postscript options were extended to let
the top/bottom/left/right margins be set individually.  It would also be
convenient if there was an "inkjet" switch which changed the default margins
from 1/4" on all sides to 1/2" on the bottom (left if horizontal==T) and 1/8"
on the top (or right).

I've also made a quick hack for the postscript device that adjust the margins
appropriately.  Maybe other users of inkjet printers who use postscript will
find it useful.

--- devPS.c     Tue May  2 06:18:35 2000
+++ /eolian1/R-1.1.0/src/main/devPS.c   Thu Jun 29 16:08:13 2000
@@ -909,6 +909,13 @@
     } else {
        xoff = yoff = 0.0;
     }
+    /* HACK for DeskJet printers with 1/2" bottom margin and 1/8" top */
+    if(pd->landscape) {
+       pd->width -= 0.125; xoff += 0.25;
+    } else {
+       pd->height -= 0.125; yoff += 0.25;
+    }
+
     pd->maxpointsize = 72.0 * ((pd->pageheight > pd->pagewidth) ?
                               pd->pageheight : pd->pagewidth);
     pd->pageno = 0;

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