ggplotGrob adds white space between Yaxis title and plot

I am using the below code and getting this plot. Is there a way to remove the extra white space between Yaxis title and the plot in figure 1? When I run plot1 separately it doesn’t have the extra space, only gets added when I use ggplotGrob to add two plots together.

Code :

library(gtable)
require(grid)
g1 <- ggplotGrob(plot1)
g2 <- ggplotGrob(plot2)
g <- rbind(g1, g2, size = "last")
grid.newpage()
grid.draw(g)

Hi @sfo,
Welcome to the RStudio Community Forum.

I suggest you try the patchwork package - designed for placing multiple plots on a page. See
https://patchwork.data-imaginist.com/

HTH

Thanks for the reply.

I tried library egg using below code and it worked
library(egg)
ggarrange(plot1, plot2, ncol=1)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.