I'm trying to remove gridlines from an interact_plot
in R Studio, which I understand uses plotting from ggplot2.
I have tried the following code from 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())
)
But I get this error message:
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
I also get the same error message when trying to use a theme (e.g. theme_bw()
).
Any help is much appreciated!
The function interact_plot
returns an object of type ggplot and then it can be modified afterwards and not directly inside this function:
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