编辑grid.arrange标题的样式。粗体,斜体等 [英] Edit style of grid.arrange title. Bold, italic etc. R

查看:1097
本文介绍了编辑grid.arrange标题的样式。粗体,斜体等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在R中使用 grid.arrange 创建了一个多图,并且想要改变我的标题以便它是粗体(如果可能,则是斜体)。

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?

推荐答案

我已经完成了自己的工作。

I've worked it out myself..

可以使用textGrob函数来创建一个文本元素,然后将其传递给 grid.arrange 顶部函数, 。

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.

这篇关于编辑grid.arrange标题的样式。粗体,斜体等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆