[R] Margin question

Prof Brian D Ripley ripley at stats.ox.ac.uk
Mon Nov 27 08:43:46 CET 2000

On Sun, 26 Nov 2000, Janos A. Csirik wrote:

> I am trying to produce a postscript plot consisting of rectangles and text
> labels in R.  It is going very well, but I have been unable to get small
> margins on the page.  I read the documentation on the 'mar' and 'oma'
> options, but they claim that the margins should default to being 0.25in
> wide, in fact on my plot they are more like 1in each!  Here is the

Which margins?  The margins of the postscript device region are 0.25in
around the edge of the paper.  There are two more margins: see 
R-intro.  'mar' sets the margins of the plot within a figure, and
'oma' the margins of the figure within the devion region.

> smallest R script that illustrates my problem:
> postscript ( "janos.ps", paper="letter" )

add par(mar=rep(0,4))

> plot.new()
> rect ( 0, 0, 1, 1, col="yellow", border=0 )
> dev.off()
> Could you kindly suggest an extra command (or two) to insert, which would
> make the margins very small?  Please drop a copy of your reply to my email
> address, janos at research.att.com

The device region (in big points) is  18 18 594 774, and that's also the
figure region.  HOWEVER, you have not set a coordinate system, and by
default that has a 4% margin.  Try

postscript ( "janos.ps", paper="letter" )
plot(c(0,1), c(0,1), type="n", xaxs="i", yaxs="i", bty="n")
rect ( 0, 0, 1, 1, col="yellow", border=0 )

Using plot.new from user code is almost always a mistake.

If you don't want the paper margins then you probably do not want to print,
and you should set paper="special" and width and height in the postscript

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

More information about the R-help mailing list