1

I have a plot in which I'd like to show models of how three terms are related across three different categorical subgroups. sjPlot::plot_model automatically creates a kind of faceting with three plots in one row. In general, this works well. For a presentation I have some other plots that have four subgroups, however, and are plotted in a two by two grid. So that the y-axis doesn't differ substantially, I'd like to change the 1x3 faceting to 2x2 faceting with something like two plots on one row and one plot on a second row. I've tried to add + facet_wrap() without success. Can anyone suggest a way to convert a 1x3 plot_model object to a 2x1/1x1 plot? Ideally, there is still only one x-axis title, one y-axis title and one legend.

# 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

Omar Wasow
  • 1,870
  • 24
  • 24

1 Answers1

1

Change the nrow parameter of the facet part inside the plot object.

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

Vons
  • 3,277
  • 2
  • 16
  • 19