如何使用具有多个主持人或交互的 sjPlot plot_model 更改方面选项

问题描述

我有一个图,我想在其中展示三个术语如何在三个不同的分类子组之间相关的模型。 sjplot::plot_model 自动创建一种分面,在一行中包含三个图。一般来说,这很有效。然而,对于演示文稿,我还有一些其他的图,它们有四个子组,并以二乘二的网格绘制。为了使 y 轴没有显着差异,我想将 1x3 分面更改为 2x2 分面,例如一行上的两个图和第二行的一个图。我尝试添加 + facet_wrap() 没有成功。任何人都可以建议一种将 1x3 plot_model 对象转换为 2x1/1x1 绘图的方法吗?理想情况下,仍然只有一个 x 轴标题一个 y 轴标题一个图例。

# example of 1x3 plot_model output
mtcars %>% 
  mutate(cyl_fct = as.factor(cyl)) %>% 
  lm(mpg ~ wt * vs * cyl_fct,data = .) %>% 
  plot_model(type = "pred",terms = c("wt","vs","cyl_fct"))

example 1x3 plot_model plot

解决方法

更改绘图对象内刻面部分的 nrow 参数。

x=mtcars %>% 
  mutate(cyl_fct = as.factor(cyl)) %>% 
  lm(mpg ~ wt * vs * cyl_fct,data = .) %>% 
  plot_model(type = "pred",terms = c("wt","vs","cyl_fct")) 

x$facet$params$nrow=2

x

enter image description here