How to adjust the Font Size of tableGrob

南楼画角 提交于 2019-12-09 07:57:00

问题


Any idea how to adjust the font size of a tableGrob? I am using gridExtra 2.0.0, which seem to be very different previous version 0.9.3.

g <- tableGrob(mtcars)
grid.arrange(g)

I am looking to adjust the font size of the text in the table, header, and rowname as well.


回答1:


You can do this via themes:

mytheme <- gridExtra::ttheme_default(
    core = list(fg_params=list(cex = 2.0)),
    colhead = list(fg_params=list(cex = 1.0)),
    rowhead = list(fg_params=list(cex = 1.0)))

myt <- gridExtra::tableGrob(mtcars[1:5, 1:5], theme = mytheme)

grid.draw(myt)

There are a number of other examples in browseVignettes("gridExtra") -- look at the tableGrob examples. A great deal of control is possible.




回答2:


You can also change the general font size easily with base_size

grid.draw(tableGrob(head(mtcars, n=10),theme=ttheme_minimal(base_size = 5) ))


来源:https://stackoverflow.com/questions/31776557/how-to-adjust-the-font-size-of-tablegrob

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!