I would really like to make a figure in R that has two panels in the top row and three in the bottom row. I would like to pull this off using the base graphics package. I do not want to use ggplot. Thoughts?
Asked
Active
Viewed 363 times
-2
-
Corresponding dupe for `ggplot` [here](http://stackoverflow.com/questions/8112208/how-can-i-obtain-an-unbalanced-grid-of-ggplots) – Henrik Mar 27 '15 at 20:22
-
I do not want to do this in ggplot. – colin Mar 27 '15 at 20:24
-
@colin the link is there to help people searching for the same question but wanting to use ggplot. – Gregor Thomas Mar 27 '15 at 20:25
-
@colin In your original post you wrote "but i'll deal with ggplot if I must". That's why I posted the `base` `layout` solution as a the 'close dupe', and pointed you to the `ggplot` version in the comment. Feel free to use what suits your needs best. – Henrik Mar 27 '15 at 20:27
1 Answers
3
plot.mat = matrix(c(1, 1, 1, 2, 2, 2,
3, 3, 4, 4, 5, 5),
nrow = 2, byrow = T)
layout(plot.mat)
layout.show(n = 5)
# looks good
for (i in 1:5) plot(rnorm(10), rnorm(10))
The ?layout
help is well-written and has plenty of examples.

Gregor Thomas
- 136,190
- 20
- 167
- 294
-
-
These days it's easy to jump into `ggplot` and not learn base graphics, but I'm surprised you hadn't seen `layout`, it's quite common. `par(mfrow)` would work if you didn't care about balance, and `split.screen` could also be made to do it, but this isn't a great use case for it. If you're looking for the hard way to do it, it could be done with `par(plt)`. – Gregor Thomas Mar 27 '15 at 20:22