我正在用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())
pps:根据我在网上找到的sjPlot资源,应该有比我看到的更多的sjPlot主题。太奇怪了。此外,我还读到set_theme()函数应该与ggplot2主题一起工作,这里的情况似乎并非如此。知道窃听器在哪里吗?也许我是在监督一些很简单的事情?
编辑:我正在使用R版本3.5.0和Rstudio版本1.1.383,谢谢!!
发布于 2018-10-04 13:01:02
主题-选项改变网格和轴标签等的外观,但不改变地理(如点或线)的外观。因此,您可以在colors-argument中使用plot_model()。有一些例子,在这个小故事里。我想你的解决办法是:
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")

https://stackoverflow.com/questions/52642858
复制相似问题