【问题标题】:Change font family in interaction plot in R在R中的交互图中更改字体系列
【发布时间】:2015-09-29 21:45:09
【问题描述】:

我正在使用 sjPlot - 一个基于 ggplot2 构建的包,我是新手 - 我正在尝试将字体系列更改为 Times New Roman。使用示例代码:

require(sjPlot); require(effects)
fit <- lm(weight ~ Diet * Time, data = ChickWeight)
sjp.int(fit, type = "eff")

但是,当我尝试添加如下参数时:

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

它不起作用;当我尝试在sjp.setTheme() 中输入类似的代码时也不会。有什么想法吗?谢谢。

【问题讨论】:

    标签: r plot fonts ggplot2


    【解决方案1】:

    sjp.SetTheme 不允许您指定字体系列(您会发现它从 arg 列表中丢失)。我不想通过all of this code 来弄清楚如何更改该函数以提供字体系列规范,但我能够通过theme_set 更改字体系列:

    library(sjPlot)
    library(effects)
    library(ggplot2)
    data("ChickWeight")
    fit <- lm(weight ~ Diet * Time, data = ChickWeight)
    
    theme_set(theme_bw(base_family = 'AR BERKLEY'))
    sjp.int(fit, type = "eff") 
    

    theme_set(theme_bw(base_family = "Times New Roman"))
    sjp.int(fit, type = "eff") 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-02
      • 2015-02-25
      • 2019-08-21
      • 1970-01-01
      • 2021-11-07
      • 2018-01-03
      相关资源
      最近更新 更多