I am trying to move subplots closer together with R.
What I am doing is basically not important, but just for the sake of fast reproducing, here is the code:
library(igraph)
library(plyr)
g<-graph.ring(10)
setEPS()
postscript( 'out.eps', horizontal=F, onefile=F, paper="special", fonts=c("serif", "Palatino"))
par( mfrow = c( 1, 5 ) )
for (i in 1:5){
plot(g)
title(main='title', cex.main=1.2)
}
dev.off()
and as an output I am getting:
I know that I can organize it in a 2x3 layout, not 1x5, but this is not important. The thing is, that there is a lot of free space between each subplots, and I would like to place them as tight as possible.
Is there a way to achieve it?
P.S. this question sounds like relevant, but in fact it is not.
You just need to add:
par(mar = c(5,0,4,0))
to adjust the margins of each plot. There is another way of adjusting the margins by setting mai
What I usually do is use the omi ('c(bottom, left, top, right)') and plt ('c(x1, x2, y1, y2)') arguments in par. omi sizes the outer margins in inches and plt gives the coordinates of the plot region as a fraction of the figure region. Use ?par for a more detailed explanation and more arguments.
par(mfrow = c(2,3), omi=c(0.5,0.3,0,0), plt=c(0.1,0.9,0,0.7))
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