[R] extra whitespace around EPS files

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jan 4 08:55:36 CET 2002


On Thu, 3 Jan 2002, Michael D. Sohn wrote:

> I'm having difficulty getting rid of extra whitespace above and below an
> EPS figure.  For example, if  I generate an output file using these
> commands:
>
> > R.test(output='none')

Well, that doesn't generate any!  The example can be simpified to work, or
R.test("yes") used.

> where:
>
> R.test <- function(output=NULL) {
>   if (output == 'yes') {
>     ps.options(pointsize=10)
>     postscript('plot.eps', paper='special', horizontal=FALSE,
> onefile=FALSE, height=3, width=6)
>   }
>   plot(rnorm(10), rnorm(10))
>   if (output == 'yes') {
>     dev.off()
>     ps.options(reset=TRUE)
>   }
> }
>
>
> I get a  bunch of extra whitespace above and below the figure.  However,
> if I increase the height to say 5inches, the whitespace is gone.

Not so for me (I get the same whitespace at 5" high).  The whitespace you
are seeing is the margins, and you have a rather large pointsize for a 3"
high plot, so have large margins.

Take a look at R-intro.  You probably want to set

par(mar=c(5.1, 4.1, 0, 0))

> Presumably the extra whitespace was filled up by the figure.  Is there a
> way to get rid of the whitespace?  Even editing the bounding box of the
> EPS figure didn't really help.

Does for me:

auk% gs -sDEVICE=bbox plots.eps
...
%%BoundingBox: 3 13 408 172

gives a correct tight bounding box.

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