20

I dont seem to be able to find a solution as to how to increase the space between two plots with grid.arrange. I find no clue as to how to proceed. I dont want to change the size of the plots or anything like that.

grid.arrange(plot1, plot2, ncol=2)

(The stuff below was added later):

This is the code that I have:

x11()

cs <- grid.arrange(arrangeGrob(b, a, ncol=2, top = textGrob(
                    "B", vjust = 0.5, hjust = 19.5, gp = gpar(
                     fontface = "bold", cex = 1.5)),
                     left = textGrob(~ Delta * "SCR (p - d)" ~ mu * 'S', 
                     gp=gpar(fontsize=18), rot = 90, vjust = 1)))
soc_sph <- grid.arrange(arrangeGrob(p, g, ncol=2, top = textGrob(
                     "A", vjust = 0.5, hjust = 19.5, gp = gpar(
                     fontface = "bold", cex = 1.5)),
                     left = textGrob(~ Delta * "SCR (p - d)" ~ mu * 'S', 
                     gp=gpar(fontsize=18), rot = 90, vjust = 1)))

grid.arrange(soc_sph, cs, ncol=2)

So it is in this last grid.arrange, the space between soc_sph and cs that is to be increased.

augusti
  • 401
  • 3
  • 6
  • 16
  • Possible duplicate of [reduce space between grid.arrange plots](http://stackoverflow.com/questions/13299496/reduce-space-between-grid-arrange-plots) – Axeman Sep 15 '16 at 11:47

1 Answers1

28

the standard way is to change the plot margins,

pl = replicate(3, ggplot(), FALSE)
grid.arrange(grobs = pl)  # default settings

enter image description here

margin = theme(plot.margin = unit(c(2,2,2,2), "cm"))
grid.arrange(grobs = lapply(pl, "+", margin))

enter image description here

baptiste
  • 75,767
  • 19
  • 198
  • 294
  • how to do if grobs are "gTrees" like in this post? https://www.biostars.org/p/191971/ – Brian Wiley Sep 30 '20 at 12:54
  • figured way with lmat, lhei, lwid using `lmat = rbind(c(0,0,0,0), c(0,4,3,0), c(0,2,1,0), c(0,0,0,0))`, `lhei = c(0.5, 1.5, 4, 0.5)`, `lwid = c(0.5, 1.5, 4, 0.5)` – Brian Wiley Sep 30 '20 at 13:07