将SJPLOT的几个预测图放在一个窗口中

发布于 2025-01-20 16:56:04 字数 870 浏览 4 评论 0原文

使用“ pred”函数使用SJPLOT时,我遇到了一个问题。 对于我目前的模型,模型中使用了三个预测指标。

NQuart3.1 <- 
  glmmTMB(Pos_count ~ Predsumscale + Buildscale + 
          (1|Territory),
          offset = log(Ndays),
          dispformula = ~Roadscale + Buildscale, 
          data = NightQuart3, 
          family = nbinom1(link = "log")
          )

当我在此上使用sjplot时,它将为我提供2个单独的图形。 一个用于buildscale,另一个用于predsumscale,分开。

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'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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

场罚期间 2025-01-27 16:56:04

我不知道一种讲述plot_model()明确地说“请将所有这些都放在同一绘图窗口中”的方法,但是有许多简单的方法可以采用绘图对象并将组件呈现一个带有不同布局的窗口。

设置:

library(glmmTMB)
m1 <- glmmTMB(mpg ~ disp + hp, mtcars)
library(sjPlot)
pp <- plot_model(m1, type = "pred")

sjplot具有plot_grid(),但似乎不是很灵活。

sjPlot::plot_grid(pp)

gridExtra::grid.arrange(grobs=pp)

cowplot具有plot_grid(),还有更多选项

cowplot::plot_grid(plotlist = pp)

patchwork可能是最灵活的。

library(patchwork)
pp[[1]] + pp[[2]]

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]]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文