Add extra spacing between a subset of plots Add extra spacing between a subset of plots r r

Add extra spacing between a subset of plots


The layout() function is your friend. You could for example define a plot matrix

1 23 45 67 8

and then put empty plots in for the third and fourth. Or just stick to six and call par to add extra spacing at the bottom.


I can think of three ways:

1) Use the mar graphic parameter to set plot margin

You can retrieve current margins with

currmar <- par()$mar

You can set new margins with

par("mar"=c(5, 4, 4, 2))

with the for numbers being bottom, left, top and right margins (see ?par)

You can make multiple calls to par for each plot, so you can change the bottom margin only for the top plots.

2) Use layout to generate an uneven layout grid (see ?layout for examples)

3) Save the plot in .svg or .pdf and then use Inkscape (or whatever software you like) to move the plots.


I think going with mar is the way I would do it. However, as it looks like, you want all the plots to be the same. Therefore, you need to have the same amount taken off by mar on every plot on top and bottom.
In your case one could use the following numbers:
1. row: par(mar=c(7,4,4,2))
2. row: par(mar=c(5,4,6,2))
3. row: par(mar=c(7,4,4,2))

This way all plots occupy the same height. Modifie the first and third number in such a way that they are the same for each plot to accomplish this.However, on caveat: There is some extra white space below the plots in the bottom row.