[R] Same plot size with mfrow()

David Winsemius dwinsemius at comcast.net
Wed Jul 10 02:12:46 CEST 2013


On Jul 9, 2013, at 3:23 PM, Charlie Brown wrote:

> Hello,
> 
> I want to plot similar to the example below.  I want to remove the X and Y
> axis labels to avoid redundancy, but then want to make the spaces between
> plots smaller.  When I do this (see below), I end up with plots of
> different sizes (I want the plots to be exactly the same dimensions).
> Could someone help me with this multiple plot setup, I'm sure this is way
> too complicated and simpler code will accomplish my goals.  Thanks, Charlie
> 
> 
> png("example.png", height=1000, width=1500)
> 
> par(mfrow=c(2, 2), cex=2, cex.lab=1.5, cex.axis=1.5, cex.main=2, mgp=c(3,
> 1, 0), omi=c(3, 5, 2, 1))

Those omi values aRE TOO LARGE.
> 
> par(mar=c(1, 5, 2, 1)+0.1)
> plot(c(1:100), c(1:100), xaxt="n", ylab="Y-label 1")
> 
> par(mar=c(1, 1, 2, 1)+0.1)
> plot(c(1:100), c(1:100), xaxt="n", yaxt="n")
> 
> par(mar=c(5, 5, 1, 1)+0.1)
> plot(c(1:100), c(1:100), xlab="X-label", ylab="Y-label 2")
> 
> par(mar=c(5, 1, 1, 1)+0.1)
> plot(c(1:100), c(1:100), yaxt="n", xlab="X-label 2")
> 
> dev.off()

png("example.png", height=1000, width=1500)

par(mfrow=c(2, 2), cex=2, cex.lab=1.5, cex.axis=1.5, cex.main=2, mgp=c(3,
1, 0), omi=c(2,1,1, 1), pin=c(5,4) )  # attempting to force equal sized plot dimensions
plot(c(1:100), c(1:100), xaxt="n", ylab="Y-label 1")
plot(c(1:100), c(1:100), xaxt="n", yaxt="n", ylab="")
plot(c(1:100), c(1:100), xlab="X-label", ylab="Y-label 2")
plot(c(1:100), c(1:100), yaxt="n", xlab="X-label 2", ylab="")

dev.off()


Closer, but if you wnat control over the axis labeling to avoid the irregular gaps, you need to use the `axis` function.


> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list