如何增加尺寸 grid.arrange(tableGrob, ggplotGrob)

How to increase the size grid.arrange(tableGrob, ggplotGrob)

最近开始使用 grid/gridExtra 并一直在想办法增加 grob 的大小。不知道为什么,纸上似乎还剩下很多房地产优势 space。如何增加尺寸?以下是 knitr 和 rmarkdown 生成的 PDF。

---
title: "Untitled"
output: pdf_document
classoption: landscape
---


```{r, echo=FALSE}
library(gridExtra)
library(ggplot2)
a <- read.csv(text='"State","Abbreviation", "age"
"Alabama","AL", "7"
"Alaska","AK", "8"
"Arizona","AZ", "3"
"Arkansas","AR", "4"
"California","CA", "4"')

tbla <- tableGrob(a, )
tblb <- ggplotGrob(ggplot(cars, aes(dist, speed)) + geom_point() + geom_smooth(method=loess))
grid.arrange(tbla, tblb)
```

您可以使用 geometry 包通过 rmarkdown 设置边距

---
title: "Untitled"
output:
  pdf_document:
    fig_width: 11
    fig_height: 7
    fig_crop: false
classoption: landscape
geometry: margin=0in
---


```{r, echo=FALSE}
library(gridExtra)
library(grid)
library(ggplot2)
a <- read.csv(text='"State","Abbreviation", "age"
"Alabama","AL", "7"
"Alaska","AK", "8"
"Arizona","AZ", "3"
"Arkansas","AR", "4"
"California","CA", "4"')

tbla <- tableGrob(a)
tblb <- ggplotGrob(ggplot(cars, aes(dist, speed)) + geom_point() + geom_smooth(method=loess))
grid.arrange(tbla, tblb, heights=unit.c(sum(tbla$heights), unit(1,"null")))
```