【发布时间】: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()
我有两个设计问题:
-
在上面的粉红色气泡中,您可以看到文本对齐存在问题。我该如何更改?
-
在下方的粉红色气泡中,灰色背景存在问题。它由 ""54" = gpar(lwd=27, lineend="butt", columns=c(2:6), col="#99999922"))," 定义,但如果我选择第 53 行或第 54 行这没用。所以灰色背景不适合文字。
有人可以帮忙吗?谢谢!
【问题讨论】:
-
有人有想法吗?
-
这不是森林地块。在 Wikipedia 页面或包作者的教程中查看该术语的公认用法。 cran.r-project.org/web/packages/forestplot/vignettes/…
标签: r plot forestplot