如何更改Metafor中森林图的点颜色()
我有一个使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
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