R sjPlot-将打印线颜色更改为黑色/白色

R sjPlot-将打印线颜色更改为黑色/白色,r,ggplot2,colors,themes,sjplot,R,Ggplot2,Colors,Themes,Sjplot,我正在用sjPlot的plot\u model()绘制回归模型。我想将线条颜色从sjPlot主题(红色和蓝色线条)更改为黑白或灰度。但是,当我使用set\u-theme(theme\u-bw())时,绘图外观不会改变(theme\u-bw是从ggplot2中获得的,这是根据我在键入函数时看到的下拉列表) 但是,当我选择一个可用的sjPlot主题(theme\u 538,theme\u blank,theme\u sjPlot和theme\u sjplot2)时,绘图外观会发生变化,这些主题都会将

我正在用sjPlot的
plot\u model()
绘制回归模型。我想将线条颜色从sjPlot主题(红色和蓝色线条)更改为黑白或灰度。但是,当我使用
set\u-theme(theme\u-bw())
时,绘图外观不会改变(
theme\u-bw
是从ggplot2中获得的,这是根据我在键入函数时看到的下拉列表)

但是,当我选择一个可用的sjPlot主题(
theme\u 538
theme\u blank
theme\u sjPlot
theme\u 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
库(ggplot2)
图书馆(sjPlot)
图书馆(sjmisc)
#设置主题(theme_bw())#这不会更改打印外观
设置主题(theme_538())#这会更改打印背景外观

主题选项改变网格和轴标签等的外观,但不改变几何图形(如点或线)的外观。因此,您可以使用
plot\u model()
中的
colors
-参数。这里有一些例子。我想你的解决方案是:

plot_model(M, type = "pred", terms = c("IV1", "IV2", "IV3 [-1,0,1]"), colors = "gs")


谢谢你的快速回答。它确实分别将我的行设置为灰度或黑白。但是,在b/w中,它不会自动区分线型(我有两条不同的线,最初为蓝色和红色),例如,正如您在渐晕图中指出的那样,使用一条实线和一条虚线。我尝试将
linetype=c(1,2)
-参数添加到
plot\u model()
中,但没有成功。有没有办法手动调整线型?我添加了一个工作示例。我不确定什么东西不适合你,也许你可以?如果要更改line Types colors=“bw”参数,我只需将主题颜色转换为黑白即可。
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")