简体   繁体   English

R gridExtra 2.0.0:tableGrob垂直和水平填充

[英]R gridExtra 2.0.0: tableGrob vertical and horizontal padding

I want to know how to do in gridExtra 2.0.0 what I could do in previous versions to change table width/height padding eg: 我想知道如何在gridExtra 2.0.0中做我在以前版本中可以做的更改表格宽度/高度填充的操作,例如:

grid.arrange(tableGrob(mtcars,padding.h=unit(1,"mm"),padding.v=unit(1,"mm")))

(Sorry I couldn't test the code above because I don't have the older version of gridExtra installed) (对不起,我没有测试较早的代码,因为我没有安装较旧的gridExtra版本)

I don't want to shrink the text, just want to tighten everything together so the table fits where I'm putting it on a PDF page. 我不想缩小文本,只是想将所有内容都紧缩在一起,以便表格适合我将其放置在PDF页面上的位置。

I can see the "widths" property has "+4mm" on every entry, but I don't know how to change those to, say, +2mm . 我可以看到“ widths”属性在每个条目上都有“ + 4mm” ,但是我不知道如何将其更改为+ 2mm

Of course I would prefer if there was a simple "padding" property I could change. 当然,如果有一个简单的"padding"属性可以更改,我会更喜欢。

My question is in a similar vein as this one . 我的问题与相似。

You have to use a theme , and as baptiste comments, you can use ttheme_default to show the properties of the default theme. 您必须使用一个主题 ,并且可以作为baptiste注释使用ttheme_default显示默认主题的属性。

ttheme_default()

To set the padding of the table "core" to 1 mm: 要将表格“核心”的填充设置为1 mm:

mytheme <- gridExtra::ttheme_default(
             core = list(padding=unit(c(1, 1), "mm"))
           )
mytable <- tableGrob(mtcars, theme = mytheme)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM