简体   繁体   中英

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:

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)

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.

I can see the "widths" property has "+4mm" on every entry, but I don't know how to change those to, say, +2mm .

Of course I would prefer if there was a simple "padding" property I could change.

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.

ttheme_default()

To set the padding of the table "core" to 1 mm:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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