Remove white space between plots and table in grid.arrange

后端 未结 2 499
逝去的感伤
逝去的感伤 2021-01-02 10:13

I would like to remove the large spacing that is inserted by default between the plots and the table in a grid.arrange, as shown in the MWE hereafter:

requir         


        
2条回答
  •  北荒
    北荒 (楼主)
    2021-01-02 10:46

    grid.arrange() by default allocates equal space for each cell. If you want a tight fit around a specific grob, you should query its size, and pass it explicitly,

    library(grid)
    th <- sum(table$heights) # note: grobHeights.gtable is inaccurate
    grid.arrange(plots, table, heights = unit.c(unit(1, "null"), th))
    

提交回复
热议问题