问题
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