r - Adding white space after ggplots using grid.arrange -


i'm creating ggplots in loop , using grid.arrange plot each of figures on 1 page in lattice-type graph. problem have have border around each figure , merge when plot them. know how add white space between figures. i've looked information figure padding , toyed around trying add blank geom_rect between plots, far no luck. simplified code provided below. can offer.

p = vector("list", 3) #list arranging grid  for(ii in 1:3){   p[[ii]] = ggplot(mtcars, aes(x = wt, y = mpg))+     geom_point()+     theme(plot.background = element_rect(colour = 'black', size = 2)) } do.call("grid.arrange", c(p, ncol=1)) 

i tried quite few different efforts viewports smaller within 3 x 1 layout , realized adding blank space narrow heights in 5 x 1 layout pretty easy:

layout <- grid.layout(nrow = 5, ncol = 1,                        heights=c(1, .1, 1, .1, 1) ) # have written code alternate heights or widths gaps grid.show.layout(layout) vplayout <- function(...) {  # sets new page layout      grid.newpage()      pushviewport(viewport(layout = layout))  }  subplot <- function(x, y) viewport(layout.pos.row = x,      layout.pos.col = y)  mmplot <- function(p=p) { # make more general      vplayout()      print(p[[1]], vp = subplot(1, 1 ))      print(p[[2]], vp = subplot(3, 1))      print(p[[3]], vp = subplot(5, 1 ))  }  mmplot(a, z) 

enter image description here


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -