Use outer margins. Try something like: > par(mfrow=c(3,1), mar=c(0,4,0,2)+0.1, oma=c(5,0,3,0)+0.1 )
Then do your plots without resetting margins. Also you can use xaxt='n' rather than axes=FALSE to suppress just the x axis and not have to do the y axis and box by hand. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Peter Neuhaus > Sent: Thursday, February 18, 2010 10:11 AM > To: r-help@r-project.org > Subject: [R] problem with multiple plots (mfrow, mar) > > Dear R-users, > > I often stack plots that have the same x-axis. To save space and have > the plots themselves as large as possible I like to minimize the > margins > between the plots to zero. I use the "mfrow" and "mar" parameters to > achieve this. > > However, the different margin settings for the individual plots lead to > the inner plots being higher than the two outer plots. To make the > data in the individual subplots visually comparable, I would like > to have all plots with a plotting area of exactly the same height. > > How would that be done in R? > > Here's some example code to illustrate my problem: > > # BEGIN > x <- 1:10 > a <- runif(10, 0, 5) > b <- runif(10, 0, 5) > c <- runif(10, 0, 5) > > ylim <- c(0, 5) > > par(mfrow=c(3,1)) > par(mar=c(0,4.1,2.1,3.1)) > > plot(x, a, type="o", ylim=ylim, axes=FALSE) > axis(1, labels=FALSE) > axis(2) > axis(3) > axis(4) > box() > > par(mar=c(0,4.1,0,3.1)) > > plot(x, b, type="o", ylim=ylim, axes=FALSE) > axis(1, labels=FALSE) > axis(2) > axis(3, labels=FALSE) > axis(4) > box() > > par(mar=c(2.1,4.1,0,3.1)) > > plot(x, c, type="o", ylim=ylim, axes=FALSE) > axis(1) > axis(2) > axis(3, labels=FALSE) > axis(4) > box() > # END > > Thanks in advance, > > Peter > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.