【问题标题】:Forest Plot Design questions森林地块设计问题
【发布时间】:2020-06-23 08:58:37
【问题描述】:

我正在使用 forestplot() 函数创建森林图。

森林图如下所示: Forest Plot

    ## Labels defining subgroups are a little indented!
subgps <- c(4,5,8,9,12,13,16,17,20,21,24,25,28,29,32,33)
data$Variable[subgps] <- paste("  ",data$Variable[subgps]) 
align = c("l", "l", "l", "l", "l", "l", "l", "l", "l", "l", "l")

library(forestplot)
png(file.path(workdir,"Figures\\Forestplot3.png"),width=1280, height=1000)
forestplot(labeltext=tabletext, graph.pos=3, 
           mean=c(NA,NA,data$Point.Estimate), 
           lower=c(NA,NA,data$Low), upper=c(NA,NA,data$High),
           title="Hazard Ratio",
           xlab="<---favors no ß-blockers---  ---favors ß-blockers--->", xlab.position="left",
           hrzl_lines=list("3" = gpar(lwd=1, col="#99999922"), 
                           "5" = gpar(lwd=60, lineend="butt", columns=c(2:6), col="#99999922"),
                           "14" = gpar(lwd=85, lineend="butt", columns=c(2:6), col="#99999922"),
                           "23" = gpar(lwd=60, lineend="butt", columns=c(2:6), col="#99999922"),
                           "31" = gpar(lwd=60, lineend="butt", columns=c(2:6), col="#99999922"),
                           "39" = gpar(lwd=60, lineend="butt", columns=c(2:6), col="#99999922"),
                           "47" = gpar(lwd=60, lineend="butt", columns=c(2:6), col="#99999922"),
                           "54" = gpar(lwd=27, lineend="butt", columns=c(2:6), col="#99999922")),
           txt_gp=fpTxtGp(label=gpar(cex=1.25),
                          ticks=gpar(cex=1.1),
                          xlab=gpar(cex = 1.2),
                          title=gpar(cex = 1.2)),
           col=fpColors(box="blue", lines="black", zero = "gray50"),
           zero=1, cex=0.9, lineheight = "auto", boxsize=0.5, colgap=unit(6,"mm"),
           lwd.ci=2, ci.vertices=TRUE, ci.vertices.height = 0.4)
x = .353
y0 = .08
y1 = .91
grid.lines(c(x, x), c(y0, y1), default.units = "npc",
           gp = gpar(lwd = 1.7, col="#880000"))

dev.off()

我有两个设计问题:

  1. 在上面的粉红色气泡中,您可以看到文本对齐存在问题。我该如何更改?

  2. 在下方的粉红色气泡中,灰色背景存在问题。它由 ""54" = gpar(lwd=27, lineend="butt", columns=c(2:6), col="#99999922"))," 定义,但如果我选择第 53 行或第 54 行这没用。所以灰色背景不适合文字。

有人可以帮忙吗?谢谢!

【问题讨论】:

标签: r plot forestplot


【解决方案1】:

为了对齐,您应该能够在参数中使用align。对于后者,这很可能只是您的图表太大的情况,请尝试将高度增加到 1200,看看是否可以解决您的问题。您的示例缺少labeltext,因此很难测试这是否能解决您的问题。

【讨论】:

  • 谢谢@Max。不幸的是,以前看到你的答案。我已经使用了 align 参数,但它不起作用。我在一开始就在上面进行了编辑。你能帮忙吗?
  • @MaxGordon 有几个使用 forestplot 软件包的统计幼稚用户使用它在单个研究中生成多个混杂因素的风险或优势比的图形显示。您的小插曲正确地描述了使用术语森林图来描述多项研究结果的图形表示,但绘图的灵活性似乎让人们认为,因为他们使用了forestplot 函数,所以他们产生了“森林图” ”。理想情况下,这将在帮助页面中明确说明,并可能在加载包时显示一条消息
  • @IRTFM - 是的,仅仅因为它编译它并不一定是正确的。我认为警告没有那么有用——毕竟向我们抛出的所有 cookie 警告和其他警告我认为我们大多数人已经对它们免疫(即简单地忽略它们)。改进文档总是一件好事,请考虑在 GitHub 上提交 PR,我很乐意看看
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-08
  • 2017-10-17
  • 2016-03-02
  • 2017-03-15
  • 2021-06-12
相关资源
最近更新 更多