sjPlot 交互 plot_model。如何在主要网格线之间绘图,编辑图形以获得视觉吸引力

sjPlot interaction plot_model. How to plot between major grid lines, edit graph for visual appeal

我正在尝试绘制包含交互的模型的预测值。我想将 x 轴值(因子)的位置移动到更靠近图表中心的位置。目前使用 sjPlot,plot_model() 函数,我尝试使用 grid.breaks= 但这只适用于数值。此外,我尝试的一切,这些值似乎只沿着主要网格线绘制。有没有办法在主要网格线之间绘制?或者有没有办法在 ggplot2 中做到这一点? TIA

library("sjPlot")
data("mtcars")
mtcars$gear <- factor(mtcars$gear)
mtcars <- subset(mtcars,!gear=="3")
mtcars$gear <- factor(mtcars$gear)
levels(mtcars$gear)
m_gear <- lm(mpg ~ gear*wt, data = mtcars)
plot_model(m_gear, type = "int", grid.breaks = 0.5)

graph output

您可以使用 coord_cartesian。当您有因数时,它们在 x 轴上被编码为 1,2,因此设置超出该范围的限制将为您提供所需的内容,请参阅:

plot_model(m_gear, type = "int") + coord_cartesian(expand = TRUE,xlim=c(0,3))

plot_model(m_gear, type = "int") + coord_cartesian(expand = TRUE,xlim=c(0.5,2.5))