如何更改Metafor中森林图的点颜色()

发布于 2025-02-11 20:17:02 字数 842 浏览 0 评论 0原文

我有一个使用metafor :: forestplot()构建的森林图,并且我想根据具有两个级别的分组变量(dat $ target_status ='targeted'或'notargeted')为点和顺式着色。将颜色通过向量并进入森林()'col'对我不起作用。以下代码更改了摘要多边形,但没有要点和胡须:

cols <- c("red", "blue")[match(dat$target_status, c("targeted", "nontargeted"))]

forest(res.overall, xlim=c(-8, 6), #at=log(c(0.05, 0.25, 1, 4)), #atransf=exp,
       #ilab=cbind(dat$tpos, dat$tneg, dat$cpos, dat$cneg),
       #ilab.xpos=c(-9.5,-8,-6,-4.5), 
       cex=0.75, 
       ylim=c(-3, 53),
       order=order(factor(dat$region4, level=c("south","north islands", "central","north")),dat$target_status, dat$yi), 
       rows=c(4:11,17:22,28:35,41:47),
       mlab=mlabfun("biomass overall", res.overall),
       slab=paste(dat$group),
       col=cols,
       #showweights = TRUE,
       #psize=1.3, 
       header="Region | Monitoring Group")

I have a forest plot constructed using metafor::forestplot() and I'd like to color the points and CIs based on a grouping variable that has two levels (dat$target_status = 'targeted' or 'nontargeted'). Passing the colors through a vector and into forest() 'col' did not work for me. The following code changes the summary polygon, but not the points and whiskers:

cols <- c("red", "blue")[match(dat$target_status, c("targeted", "nontargeted"))]

forest(res.overall, xlim=c(-8, 6), #at=log(c(0.05, 0.25, 1, 4)), #atransf=exp,
       #ilab=cbind(dat$tpos, dat$tneg, dat$cpos, dat$cneg),
       #ilab.xpos=c(-9.5,-8,-6,-4.5), 
       cex=0.75, 
       ylim=c(-3, 53),
       order=order(factor(dat$region4, level=c("south","north islands", "central","north")),dat$target_status, dat$yi), 
       rows=c(4:11,17:22,28:35,41:47),
       mlab=mlabfun("biomass overall", res.overall),
       slab=paste(dat$group),
       col=cols,
       #showweights = TRUE,
       #psize=1.3, 
       header="Region | Monitoring Group")

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

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

发布评论

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

评论(1

旧人九事 2025-02-18 20:17:02

您需要使用colout参数。请参阅文档:

https://wviechtb.github.io/metaub.io/metafor/reference/ Forest.rma.html

You need to use the colout argument. See the documentation:

https://wviechtb.github.io/metafor/reference/forest.rma.html

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