I’ve got 16 plots on a page, arranged in a 4×4 grid. I’d like to have a border around each set of 2×2, but can’t work out how to do it.
I initially used layout(matrix(c(1,2,5,6,3,4,7,8,9,10,13,14,11,12,15,16), 4, 4, byrow=TRUE)) to create the correct layout, but, as far as I know, there’s no way of creating margins that extend beyond both the current plot and any subsequent plot that the margin would overlap.
The 2nd approach I tried was to use split.screen(), thinking that any oma() settings would only apply to the current screen, however, it appears to apply to the whole window; for example, the following code produces a border at the outer of the whole display area, not screen(1):
depths <- c(1:10)
split.screen(c(2,2))
screen(1)
par(oma=c(1,1,1,1))
plot(depths)
box("inner", lty="dotted", col="green")
Trying various things with either box("inner") or box("outer") after setting oma settings doesn’t create the desired result.
Are there any other obvious approaches I should be trying?
Thanks,
Chris
Here is a way using layout:
Adjust it to your preferences.