[R] Par and the size of the page

Paul Murrell paul at stat.auckland.ac.nz
Fri Jun 15 02:05:27 CEST 2001


Hi


> I've been trying, without much success, to change the properties of the
> device on the Windows (1.3.0) version of R.  What I'm trying to do is move
> the plots further away from each other on the device (which will hopefully
> translate to the same on the printout) and get the top plot closer to the
> top and the bottom closer to the bottom.
>
> I've sized the device to 8.5x11 using
>
> windows(width=8.5, height=11)
> split.screen(c(2,1))
> screen(1)
> x <- 1:10
> plot(x)
>
> screen (2)
> plot(x)
>
> I just cannot get these two plot away from each other on the screen or
> printout.
>
> Any thoughts?


A couple of things you could try ...

(i)  Use the par(mar) to increase the margins around the plots.  For
example,

split.screen(c(2,1))
screen(1)
par(mar=c(10, 5, 4, 2))
x <- 1:10
plot(x)
box("figure", lty="dashed")
screen (2)
par(mar=c(5, 5, 10, 2))
plot(x)
box("figure", lty="dashed")
close.screen(all=TRUE)

(ii)  Use par(mfrow) instead of split.screen() -- its much more reliable.
For example,

par(mfrow=c(2,1))
par(mar=c(10, 5, 4, 2))
x <- 1:10
plot(x)
box("figure", lty="dashed")
par(mar=c(5, 5, 10, 2))
plot(x)
box("figure", lty="dashed")

(iii)  Stick an empty plot between the plots.  For example,
(NOTE if you are using R version > 1.2.1 then this might not work;  please
do NOT report this bug - it has been fixed for the upcoming 1.3 release
already)

par(mfrow=c(3,1), mar=c(5.1, 4.1, 4.1, 2.1))
plot(x)
box("figure", lty="dashed")
plot.new()
plot(x)
box("figure", lty="dashed")

(iv)  Control the space between the plots more accurately with a layout.
For example,

layout(matrix(c(1, 0, 2), ncol=1),
       heights=c(1, lcm(5), 1))
plot(x)
box("figure", lty="dashed")
plot(x)
box("figure", lty="dashed")


Hope that helps

Paul


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