Reputation: 1
I've come across a problem when using sjPlot using the "pred" function. With the model I currently have, three predictors are used in the model.
NQuart3.1 <-
glmmTMB(Pos_count ~ Predsumscale + Buildscale +
(1|Territory),
offset = log(Ndays),
dispformula = ~Roadscale + Buildscale,
data = NightQuart3,
family = nbinom1(link = "log")
)
when I use sjplot on this, it will provide me with 2 separate graphs. One for Buildscale and one for Predsumscale, separated.
plot_model(NQuart3.1, type = "pred",
title = "Wolf space use night estimates April - June",
axis.title = "Wolf GPS locations")
$Predsumscale
(http://127.0.0.1:26952/graphics/ede13814-0fa4-4ba3-8c20-ae47c68dcabc.png)
$Buildscale
(http://127.0.0.1:26952/graphics/fe656c83-5bb0-4692-ad35-dd23a7ce3f0a.png)
I was wondering if you can adjust the code so that it would combine both graphs in one plot window?
Not combined but just side-by-side.
This would make it a lot easier to compare models with multiple parameters.
Thanks in advance
Upvotes: 0
Views: 939
Reputation: 226662
I don't know of a way to tell plot_model()
explicitly "please put all of these in the same plot window", but there are many easy ways to take the plot object and render the components within a single window with different layouts.
Setup:
library(glmmTMB)
m1 <- glmmTMB(mpg ~ disp + hp, mtcars)
library(sjPlot)
pp <- plot_model(m1, type = "pred")
sjPlot
has a plot_grid()
, but it doesn't seem very flexible.
sjPlot::plot_grid(pp)
or
gridExtra::grid.arrange(grobs=pp)
cowplot
has a plot_grid()
with many more options
cowplot::plot_grid(plotlist = pp)
patchwork
is probably the most flexible.
library(patchwork)
pp[[1]] + pp[[2]]
Upvotes: 0