sjPlot - 将绘图线颜色更改为 black/white
sjPlot - change plot line colors to black/white
我正在使用 sjPlot plot_model()
绘制回归模型。我想将我的线条颜色从 sjPlot 主题(红色和蓝色线条)更改为黑白或灰度。但是,当我使用 set_theme(theme_bw())
时,绘图外观没有改变(theme_bw
来自 ggplot2,根据我在键入函数时看到的下拉菜单)。
然而,当我 select 可用的 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
谢谢!!
主题选项会更改网格和轴标签等的外观,但不会 geom(如点或线)。因此,您可以在 plot_model()
中使用 colors
参数。有一些例子 in this vignettes。我猜你的解决方案是:
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")
我正在使用 sjPlot plot_model()
绘制回归模型。我想将我的线条颜色从 sjPlot 主题(红色和蓝色线条)更改为黑白或灰度。但是,当我使用 set_theme(theme_bw())
时,绘图外观没有改变(theme_bw
来自 ggplot2,根据我在键入函数时看到的下拉菜单)。
然而,当我 select 可用的 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 谢谢!!
主题选项会更改网格和轴标签等的外观,但不会 geom(如点或线)。因此,您可以在 plot_model()
中使用 colors
参数。有一些例子 in this vignettes。我猜你的解决方案是:
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")