R语言 更改“交互作用”图中线的颜色

uqxowvwt  于 2023-04-18  发布在  其他
关注(0)|答案(1)|浏览(160)

任何帮助在改变主题和颜色的线条下面的图表。对象'p'包含所有的信息。

text = "
ability    edu        sales
    2.1696     1.8571  3717.1243 
     4.0558     1.8571  6030.4851 
     5.9420     1.8571  8343.8458 
     2.1696     3.8233  3796.0685 
     4.0558     3.8233  5795.6345 
     5.9420     3.8233  7795.2006 
     2.1696     5.7894  3875.0127 
     4.0558     5.7894  5560.7840 
     5.9420     5.7894  7246.5554 
"
mod_data = read.table(text = text, header = TRUE)
pacman::p_load(interactions)
fit = lm(sales ~ ability*edu, data = mod_data)
p = interact_plot(fit, pred = "ability", modx = "edu")
p

创建于2023-04-16带有reprex v2.0.2

e1xvtsh3

e1xvtsh31#

您可以通过interact_plotcolors=参数设置所需的颜色,theme可以像任何其他ggplot一样设置或调整:

library(interactions)

interact_plot(fit, pred = "ability", modx = "edu", colors = c("red", "blue", "green")) +
  theme_grey() +
  theme(legend.position = "bottom")

相关问题