我正在尝试使用 interactions
中的 interact_plot
函数绘制双向交互图。如何将字体大小更改为 Times New Roman?
这是我的代码:
interact_plot(Interac2, pred = SA, modx = RPF, alpha = .05, legend.main = "RP", x.label = "EXB", y.label = "NORCA")
最佳答案
首先,我注意到您在 jtools
中提到了 interact_plot
。那里的文档说此功能已被弃用并移至包 interactions
(我也将其编辑到您的问题中)。看着 source code on GitHub它表明最终对象是一个 ggplot
对象。这很好,因为您可以在绘制后修改此对象的“主题”。您修改主题并重新绘制它等等。
因为我在 Windows 上并且需要有关如何将字体修改为 TNY 的提示,所以我找到了 this post . interact_plot
中的一些示例对我不起作用,但我确实设法修改了那个。
library(interactions)
library(extrafont)
loadfonts(device = "win")
fit <- lm(Income ~ HSGrad * Murder * Illiteracy, data = states)
xy <- interact_plot(model = fit, pred = Murder, modx = Illiteracy, mod2 = HSGrad)
xy + theme(axis.title = element_text(family = "serif"),
legend.text = element_text(family = "serif"),
legend.title = element_text(family = "serif"),
strip.text = element_text(family = "serif"))
关于r - 使用 interact_plot(包交互)更改图形的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55438299/