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.

Reply via email to