I would like to perfectly align these plots :
Here is the R code :
library(tidyverse)
library(gridExtra)
groupes <- tribble(~type, ~group, ~p
it's probably more manageable if you can set an absolute panel size (and size the device accordingly).
justify <- function(x, hjust="center", vjust="center"){
w <- sum(x$widths)
h <- sum(x$heights)
xj <- switch(hjust,
center = 0.5,
left = 0.5*w,
right=unit(1,"npc") - 0.5*w)
yj <- switch(vjust,
center = 0.5,
bottom = 0.5*h,
top=unit(1,"npc") - 0.5*h)
x$vp <- viewport(x=xj, y=yj)
return(x)
}
library(grid)
gl <- lapply(list(p1,p2,p3),egg::set_panel_size, height=unit(1,"in"))
gl <- lapply(gl, justify, vjust="top")
gridExtra::grid.arrange(grobs=gl, nrow=1)