Edit style of grid.arrange title. Bold, italic etc. R

回眸只為那壹抹淺笑 提交于 2019-12-23 10:54:34

问题


I am creating a multi plot in R using grid.arrange, and wanted to change my title so that it is bold (and italic if possible).

As this is a general question, I will not include the code for my plots, but the code I am using to make my multi plot is:

grid.arrange(g1, g3, g4+theme(legend.position="none"),mylegend, top="Test title",
             layout_matrix=matrix(c(1,1,2,3,4,4), ncol=2, byrow=TRUE),heights=c(1,1.5,0.3))

Are there any additional arguments which can be passed to the top argument to change the font face?


回答1:


I've worked it out myself..

You can use the textGrob function to create a text element, which can then be passed to the top function of grid.arrange.

For example,

title1=textGrob("Test title", gp=gpar(fontface="bold"))
grid.arrange(g1, g3, g4+theme(legend.position="none"),mylegend, top=title1,
             layout_matrix=matrix(c(1,1,2,3,4,4), ncol=2, byrow=TRUE),heights=c(1,1.5,0.3))

This does the trick nicely.



来源:https://stackoverflow.com/questions/36008659/edit-style-of-grid-arrange-title-bold-italic-etc-r

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