在代码中更改所有 ggplot 输出的字体而不是每个绘图? [英] Change the font of all ggplot-outputs once in code instead of with every plot?

查看:64
本文介绍了在代码中更改所有 ggplot 输出的字体而不是每个绘图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

处理一个相当大的 R Markdown 文档,我想知道是否可以在某种全局设置中定义一次我的 ggplots 的字体?就像我可以使用 theme_set() 为文档中的所有绘图定义 theme_minimal() 一样.

Working with a quite huge R Markdown document, I was wondering whether it is possible to define the the font of my ggplots once in some kind of global setting? Just like I can use theme_set() to define theme_minimal() for all the plots in the document.

我尝试添加类似的东西,但它抛出了一个错误:

I tried adding something like this, but it threw an error:

theme_set(text = element_text(size=12, family="Times New Roman"))

这是可能的还是我必须为我的每个输出单独定义字体?

Is this possible or would I have to define the font for each of my outputs individually?

推荐答案

将您的自定义设置包装在 theme() 中:

Wrap your custom settings in theme():

theme_set(theme(text = element_text(size=12, family="Times New Roman")))

这篇关于在代码中更改所有 ggplot 输出的字体而不是每个绘图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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