Here is a simplified MWE of my issue. How can I edit the grids or the grid.arrange parameters so that both panels show without truncation?.
library(cowplot)
plot(1:5, 1:5)
p1 <- recordPlot()
plot(1:10, 1:10)
p2 <- recordPlot()
grids<-lapply(mget(ls(pattern="p\\d+")),as_grob)
grid.arrange(grobs=grids[1:2],ncol=2)
I tried converting each of p1
and p2
to grobs with as_grob()
and then using grid.edit(grob, vp=viewport(width=0.8, height = 0.8),gPath = grob$name)
but on calling grid.arrange, the grobs still get trunctated.
I also tried changing the margins, or widths, or heights using different combinations of grid.arrange(grobs=grids[1:2], margins=c(-2,-2,-2)), widths=c(1,1,1,1), heights=c(1,1,1,1))
Here is the actual image that inspired the MWE, you can see the grid titles being overrun and unreadable when combined