How to perfectly align an unequal number of plots (ggplot2,gridExtra) : <p>I would like to perfectly align these plots :</p>

<p><a href="https://i.stack.imgur.com/sxwpj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sxwpj.png" alt="unaligned plots"></a></p>

<p>Here is the R code :</p>

<pre><code>library(tidyverse)
library(gridExtra)
groupes &lt;- tribble(~type, ~group, ~prof, ~var,
                   1,1,1,12,
                   1,1,2,-24,
                   1,2,1,-11,
                   1,2,2,7,
                   2,1,1,10,
                   2,1,2,5,
                   2,2,1,-25,
                   2,2,2,2,
                   2,3,1,10,
                   2,3,2,3,
                   3,1,1,10,
                   3,1,2,-5,
                   3,2,1,25,
                   3,2,2,2,
                   3,3,1,-10,
                   3,3,2,3,
                   3,4,1,25,
                   3,4,2,-18)


hlay &lt;- rbind(c(1,2,3),
              c(1,2,3),
              c(NA,2,3),
              c(NA,NA,3))

p1 &lt;-  groupes %&gt;% filter(type==1) %&gt;% ggplot(aes(prof,var)) + geom_col() + facet_wrap(~group,ncol=1) +
  coord_cartesian(ylim=c(-25,25)) +
  labs(title="type 1",x="",y="")
p2 &lt;-  groupes %&gt;% filter(type==2) %&gt;% ggplot(aes(prof,var)) + geom_col() + facet_wrap(~group,ncol=1) +
  coord_cartesian(ylim=c(-25,25)) +
  labs(title="type 2",x="",y="")
p3 &lt;-  groupes %&gt;% filter(type==3) %&gt;% ggplot(aes(prof,var)) + geom_col() + facet_wrap(~group,ncol=1) +
  coord_cartesian(ylim=c(-25,25)) +
  labs(title="type 3",x="",y="")
grid.arrange(p1,p2,p3, layout_matrix=hlay)
</code></pre>

<p>I may succeed to produce a better alignment by adding <code>heights=c(1.3,1,1,1)</code> into <code>grid.arrange</code> but that is not a perfect solution. Another solution would be not to take into account the space taken by the labels, but I do not know how to do that.</p>
