# [R] Same plot size with mfrow()

David Winsemius dwinsemius at comcast.net
Wed Jul 10 06:50:00 CEST 2013

```On Jul 9, 2013, at 5:12 PM, David Winsemius wrote:

>
> 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()

Another effort, using varying mar parameters.

png("example.png", height=1000, width=1500)
par(mfrow=c(2, 2), cex=2, cex.lab=1.3, cex.axis=1.3, cex.main=2,
omi=c(.5,.5,.5,.5), mar=c(4,4,0,.2), xpd=TRUE )
plot(c(1:100), c(1:100), xaxt="n", ylab="Y-label 1", xlab="")
plot(c(1:100), c(1:100), xaxt="n", yaxt="n", ylab="",xlab="");par(mar=c(4,4,0,0))
plot(c(1:100), c(1:100), xlab="X-label", ylab="Y-label 2");par(mar=c(4,4,0,0))
plot(c(1:100), c(1:100), yaxt="n", xlab="X-label 2", ylab="")
dev.off()

--
David Winsemius
Alameda, CA, USA

```