[英]sjPlot - change plot line colors to black/white
我正在用sjPlot的plot_model()
绘制回归模型。 我想将线条颜色从sjPlot主题(红线和蓝线)更改为黑白或灰度。 但是,当我使用set_theme(theme_bw())
,绘图外观不会改变(根据键入该函数时看到的下拉菜单, theme_bw
来自ggplot2)。
但是,当我选择可用的sjPlot主题之一( theme_538
, theme_blank
, theme_sjplot
和theme_sjplot2
)时,情节外观的确发生了变化,它们都将线条渲染为红色和蓝色,但是更改了情节背景,因此我认为该功能正确。
我该如何使用bw或gs主题,或者将绘图的线颜色手动设置为黑白?
library(ggplot2)
library(sjPlot)
library(sjmisc)
#set_theme(theme_bw()) # this does not change the plot appearance
set_theme(theme_538()) # this does change the plot background appearance
M <- glm(DV ~ IV1 + IV2 + IV3 + IV1*IV2*IV3, data = data5, family = quasibinomial("logit"))
p <- plot_model(M, type = "pred", terms = c("IV1", "IV2", "IV3 [-1,0,1]"), theme = theme_get())
p
ps:根据我在网上找到的sjPlot资源,应该有比我看到的更多的sjPlot主题。 真奇怪 此外,我读到set_theme()
函数应该与ggplot2主题一起使用,在这里似乎不是这样。 任何错误的想法在哪里? 也许我监督的事情很简单?
编辑:我正在使用R版本3.5.0和Rstudio版本1.1.383谢谢!
主题选项会更改网格和轴标签等的外观,但不会更改几何图形(如点或线)的外观。 因此,您可以在plot_model()
使用colors
-argument。 在这个小插曲中有一些例子。 我想为您提供的解决方案是:
plot_model(M, type = "pred", terms = c("IV1", "IV2", "IV3 [-1,0,1]"), colors = "gs")
要么
plot_model(M, type = "pred", terms = c("IV1", "IV2", "IV3 [-1,0,1]"), colors = "bw")
library(sjPlot)
data(efc)
fit <- lm(barthtot ~ c12hour + neg_c_7 * c161sex * c172code, data = efc)
plot_model(fit, type = "pred", terms = c("neg_c_7", "c172code", "c161sex"), colors = "bw")
plot_model(fit, type = "pred", terms = c("neg_c_7", "c172code", "c161sex"), colors = "gs")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.