[R] controlling figure dimension/location

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Mar 13 10:03:17 CET 2002


"Michael D. Sohn" wrote:
> 
> I'm making two plots, one on top of the other.  On the upper plot, I do
> not print the x-label or the x-tick-label.  To reduce space, I'd like to
> keep the white space between the two figures at a minimum.  However, I
> can't figure out how to methodically reduce the space while maintaining
> the same figure dimensions for both plots.  I could add margin space
> below the lower plot and reduce space above the lower plot but that
> leaves a bunch of whitespace at the bottom of the figure.  What command
> am I missing?
> thanks,
> Mike
> 
> Example commands:
> mypar <- par(no.readonly=T)
> par(mfcol=c(2,1))
> par(mar=c(5,4,1,1))
> plot(rnorm(100), ylim=c(-3,3), xlab="", axes=F)
> axis(1, at=seq(0,100,20), labels=c("","","","","",""))
> axis(2, at=seq(-3,3,1))
> box()
> plot(rnorm(100), ylim=c(-3,3), axes=F)
> axis(1, at=seq(0,100,20))
> axis(2, at=seq(-3,3,1))
> box()
> par(mypar)


So you need more vertical space for the second than for the first plot. 
I would suggest to play with layout() and par(mar=...), but I'm not sure
whether it is easy to calculate the distances *exactly*. Other
suggestions are welcome.


If you'll need only one figure of that kind, just use something like

 par(mfcol=c(2,1))
 par(mar=c(0.5,4,5,1)) ##### changed
 plot(rnorm(100), ylim=c(-3,3), xlab="", axes=F)
 axis(1, at=seq(0,100,20), labels=c("","","","","",""))
 axis(2, at=seq(-3,3,1))
 box()
 par(mar=c(5,4,0.5,1)) ####### added
 plot(rnorm(100), ylim=c(-3,3), axes=F)
 axis(1, at=seq(0,100,20))
 axis(2, at=seq(-3,3,1))
 box()

and cut off the unused spaces with another appropriate software after
that.

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