如何从 interact_plot 中删除网格线

How to remove gridlines from interact_plot

我正在尝试从 R Studio 中的 interact_plot 中删除网格线,据我所知,它使用来自 ggplot2 的绘图。

我尝试了 ggplot2 中的以下代码:

interact_plot(
  MC_Feat_Sit, 
  pred =  Mean_Mor_Con2, 
  modx = Agreement2, 
  modx.values = c(1, 4, 7), 
  x.label = "Moral Conviction", 
  y.label = "Situational Attributions", 
  legend.main = "Agreement", 
  modx.labels = c("Strongly Disagree", "Neutral", "Strongly Agree"), 
  theme(panel.grid = element_blank())
)

但我收到此错误消息:

Mean_Mor_Con2 and Agreement2 and theme(panel.grid = element_blank()) are not included in an interaction with one another in the model.Error in names(modxvals2) <- modx.labels : attempt to set an attribute on NULL

我在尝试使用主题(例如 theme_bw())时也收到相同的错误消息。

非常感谢任何帮助!

This is the graph I'm getting

函数 interact_plot returns 一个 ggplot 类型的对象然后它可以在之后修改而不是直接在这个函数内部:

plt <- interact_plot(
  MC_Feat_Sit, 
  pred =  Mean_Mor_Con2, 
  modx = Agreement2, 
  modx.values = c(1, 4, 7), 
  x.label = "Moral Conviction", 
  y.label = "Situational Attributions", 
  legend.main = "Agreement", 
  modx.labels = c("Strongly Disagree", "Neutral", "Strongly Agree")
)

plt <- plt + theme(panel.grid.major = element_blank())

plt