I want to graph an interaction effect between two variables with one outcome in R. While I can successfully produce a graph using sjPlot:plot_model(), the interaction plot does not resize when I adjust the x-axis values. Instead, the graph that's plotted is always that of the original-size while the x- and y-axis will adjust. Below is an example using the mtcars data in R.
library(sjPlot)
library(sjmisc)
library(ggplot2)
mtcars.df <- mtcars
fit <- lm(mpg ~ hp * disp, data = mtcars.df)
plot_model(fit, type = "pred", terms = c("hp", "disp"))
I can get a graph like this in my own code. However, when I attempt to alter the x- and y-axes as seen below, the grid expands, but the graph itself does not.
plot_model(fit, type = "pred", terms = c("hp", "disp"), axis.lim = list(c(0,150),c(0,200)))
Picture of successfully graphed interaction with wildly exaggerated adjustments to the axes. The graph does not extend but the grid does.
What code can I use to adjust both the lines of my interaction effect AND those of the grid? Adjusting post-hoc with
plot_model(fit, type = "pred", terms = c("hp", "disp"))+xlim(0,150)
creates the same issue.
Post-hoc extending the graph creates the same issue.