所以我一直在四处寻找并尝试更改 brms 模型图中因子变量的颜色。 基本上,我有一个包含 5 个因素的 X 变量,我的实验测量结果为 Y(连续)。在 X 变量的 5 个水平中,我将 (1, 3, 5) 作为一个条件,将 (2, 4) 作为另一个条件。
在 Rstudio 中,当我通过 conditional_effects() 绘制 X 变量的估计值时,我得到了一个很好的图,有 5 个均值和标准条,但全黑。
我想用太多的颜色给图上色,一种颜色代表 X=(1,3,5),另一种颜色代表 X=(2,4)。
我不知道要为此目的更改 conditional_effects 对象的哪个变量。
感谢您的任何建议。
在Rstudio中,我尝试了这个,没有效果:
segmentEffect <- conditional_effects(model,effect = "segment")
myPlot <- plot(segmentEffect,plot=FALSE)[[1]] +
scale_fill_manual(values = c("1" = "cyan",
"2" = "pink",
"3" = "cyan",
"4" = "pink",
"5" = "cyan"))+
scale_colour_manual(values = c("1" = "cyan",
"2" = "pink",
"3" = "cyan",
"4" = "pink",
"5" = "cyan"))
myPlot
segmentEffect.ce <- conditional_effects(model,effect = "segment") # save the conditional effects
segmentEffect.df <-
as.data.frame(segmentEffect.ce$`segment`) # save the ce as a data frame and use it in ggplot
试试这个应该有效。