I'm using layout() in R to produce a series of 9 graphs (in a 3x3 layout)
m <- rbind(c(1,2,3), c(4,5,6), c(7,8,9))
layout(m)
I'm trying to put 2 vertical lines between the three columns in order to separate the columns from each other. box() is not appropriate as I want the rows to be linked and so don't want lines there, and I'm struggling to find any help using line() function and any ideas would be appreciated.
Thanks
What if you change the graphical parameters so that all plotting is clipped to the device region, and then add the vertical lines for separation afterwards using abline()? For example:
m <- rbind(c(1,2,3), c(4,5,6), c(7,8,9))
# Clips drawing to the device region
# See ?par for more details of the argument
par(xpd=NA)
layout(m)
# Insert you nine plots here
for(i in 1:9) {
plot(1,1)
}
# Check the correct coordinates with
# locator(), and the arguments
# accordingly. These are about right,
# if the plot region is rectangular.
abline(v=0.25)
abline(v=-1.06)
The resulting plot whould appear as below.

Anothe option is to play with layout:
layout(rbind(c(1,10, 2,11,3),
c(4,10, 5,11,6),
c(7,10, 8,11,9)),
widths=c(1, lcm(3), 1,lcm(3),1),
respect=TRUE)
## you plot your 9 plots
for(i in 1:9) {
plot(1,1)
}
## you plot the separation
plot(1,1,type='n',axes=FALSE, ann=FALSE)
## here I use a vertical line but you can plot anything (box, segments,..)
abline(v=1)
plot(1,1,type='n',axes=FALSE, ann=FALSE)
abline(v=1)

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With