Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add extra spacing between a subset of plots

I'm trying to output 6 figures into one image, in a 3x2 layout. I'd like to place extra space between the top row and the bottom two rows. Is this possible using R? I've looked through the documentation for par and plot and can't seem to find an appropriate option.

Here's some example code:

a = rnorm(100,100,10)
b = rnorm(100,100,10)

par(mfrow=c(3,2), oma=c(1,1,1,1), mar=c(2,2,2,2))
hist(a)
hist(b)
plot(a,b)
plot(a,b)
plot(a,b)
plot(a,b)

Here's what that code outputs:


alt text


Here's what I'd like it to output (I modified this image in an external editor). Note the extra space between the top row and bottom rows.


alt text


like image 719
chrisamiller Avatar asked Sep 03 '10 19:09

chrisamiller


1 Answers

The layout() function is your friend. You could for example define a plot matrix

1 2
3 4
5 6
7 8

and then put empty plots in for the third and fourth. Or just stick to six and call par to add extra spacing at the bottom.

like image 199
Dirk Eddelbuettel Avatar answered Sep 27 '22 23:09

Dirk Eddelbuettel