forestplot 在图中有异常大的蓝点
forestplot has unusually large blue dot in graph
我正在尝试创建 forestplot
,但最后一行有一个巨大的蓝点,而不是其他行的小点。知道如何解决这个问题吗? these vignettes 是我到目前为止用来创建代码的内容。我唯一的想法是大点可能是摘要的一部分(点看起来很相似)但是我没有使用摘要。
tab<-structure(list(names = c("(Intercept)", "xxx", "gender", "age"
), betas = c(54.6873516187792, 2.13385086140261, 3.26945254708992,
-0.305426541112294), upper = c(62.1308928551509, 4.60545786804931,
7.29686190386409, -0.112092252532382), lower = c(47.2438103824075,
-0.337756145244089, -0.757956809684253, -0.498760829692206)), .Names = c("names",
"betas", "upper", "lower"), row.names = c("1", "2", "3", "4"), class = "data.frame")
###################################################################
xlab<-"xxxx"
clrs <- fpColors(box="royalblue",line="darkblue")
tabletext <-list(c(NA, tab$names),append(list(expression(beta)), sprintf("%.2f", tab$betas)))
forestplot(tabletext,
mean=c(NA,tab$betas),
lower=c(NA,tab$lower),
upper=c(NA,tab$upper),
col=clrs,
xlab=xlab,
vertices = TRUE)
您可以将框的大小设置为与boxsize
统一或输入与mean
长度相同的向量
tab<-structure(list(names = c("(Intercept)", "xxx", "gender", "age"),
betas = c(54.6873516187792, 2.13385086140261, 3.26945254708992, -0.305426541112294),
upper = c(62.1308928551509, 4.60545786804931, 7.29686190386409, -0.112092252532382),
lower = c(47.2438103824075, -0.337756145244089, -0.757956809684253, -0.498760829692206)),
.Names = c("names", "betas", "upper", "lower"), row.names = c("1", "2", "3", "4"), class = "data.frame")
xlab<-"xxxx"
clrs <- fpColors(box="royalblue",line="darkblue")
tabletext <-list(c(NA, tab$names),append(list(expression(beta)), sprintf("%.2f", tab$betas)))
forestplot(tabletext,
boxsize = c(NA, .1, .1, .1, .2),
mean=c(NA,tab$betas),
lower=c(NA,tab$lower),
upper=c(NA,tab$upper),
col=clrs, xlab=xlab, vertices = TRUE)
或
forestplot(tabletext, boxsize = .1,
mean=c(NA,tab$betas),
lower=c(NA,tab$lower),
upper=c(NA,tab$upper),
col=clrs, xlab=xlab, vertices = TRUE)
查看 forestplot
的代码,您可以了解 boxsize
是如何为您计算的。您需要定义以下值:
## values needed
upper <- c(NA,tab$upper)
lower <- c(NA,tab$lower)
txt_gp <- fpTxtGp()
nr <- length(upper)
## calculation in forestplot
cwidth <- (upper - lower)
cwidth[cwidth <= 0 | is.na(cwidth)] <- min(cwidth[cwidth > 0])
textHeight <- convertUnit(grobHeight(textGrob("A", gp = do.call(gpar, txt_gp$label))), unitTo = "npc", valueOnly = TRUE)
info <- 1/cwidth * 0.75
info <- info/max(info, na.rm = TRUE)
if (any(textHeight * (nr + 0.5) * 1.5 < info))
info <- textHeight * (nr + 0.5) * 1.5 * info /
max(info, na.rm = TRUE) + textHeight * (nr + 0.5) * 1.5/4
info
# [1] NA 0.02402603 0.02857476 0.02594405 0.10882403
所以现在您应该得到与之前相同的尺寸
forestplot(tabletext,
boxsize = info,
mean=c(NA,tab$betas),
lower=c(NA,tab$lower),
upper=c(NA,tab$upper),
col=clrs, xlab=xlab, vertices = TRUE)
我正在尝试创建 forestplot
,但最后一行有一个巨大的蓝点,而不是其他行的小点。知道如何解决这个问题吗? these vignettes 是我到目前为止用来创建代码的内容。我唯一的想法是大点可能是摘要的一部分(点看起来很相似)但是我没有使用摘要。
tab<-structure(list(names = c("(Intercept)", "xxx", "gender", "age"
), betas = c(54.6873516187792, 2.13385086140261, 3.26945254708992,
-0.305426541112294), upper = c(62.1308928551509, 4.60545786804931,
7.29686190386409, -0.112092252532382), lower = c(47.2438103824075,
-0.337756145244089, -0.757956809684253, -0.498760829692206)), .Names = c("names",
"betas", "upper", "lower"), row.names = c("1", "2", "3", "4"), class = "data.frame")
###################################################################
xlab<-"xxxx"
clrs <- fpColors(box="royalblue",line="darkblue")
tabletext <-list(c(NA, tab$names),append(list(expression(beta)), sprintf("%.2f", tab$betas)))
forestplot(tabletext,
mean=c(NA,tab$betas),
lower=c(NA,tab$lower),
upper=c(NA,tab$upper),
col=clrs,
xlab=xlab,
vertices = TRUE)
您可以将框的大小设置为与boxsize
统一或输入与mean
tab<-structure(list(names = c("(Intercept)", "xxx", "gender", "age"),
betas = c(54.6873516187792, 2.13385086140261, 3.26945254708992, -0.305426541112294),
upper = c(62.1308928551509, 4.60545786804931, 7.29686190386409, -0.112092252532382),
lower = c(47.2438103824075, -0.337756145244089, -0.757956809684253, -0.498760829692206)),
.Names = c("names", "betas", "upper", "lower"), row.names = c("1", "2", "3", "4"), class = "data.frame")
xlab<-"xxxx"
clrs <- fpColors(box="royalblue",line="darkblue")
tabletext <-list(c(NA, tab$names),append(list(expression(beta)), sprintf("%.2f", tab$betas)))
forestplot(tabletext,
boxsize = c(NA, .1, .1, .1, .2),
mean=c(NA,tab$betas),
lower=c(NA,tab$lower),
upper=c(NA,tab$upper),
col=clrs, xlab=xlab, vertices = TRUE)
或
forestplot(tabletext, boxsize = .1,
mean=c(NA,tab$betas),
lower=c(NA,tab$lower),
upper=c(NA,tab$upper),
col=clrs, xlab=xlab, vertices = TRUE)
查看 forestplot
的代码,您可以了解 boxsize
是如何为您计算的。您需要定义以下值:
## values needed
upper <- c(NA,tab$upper)
lower <- c(NA,tab$lower)
txt_gp <- fpTxtGp()
nr <- length(upper)
## calculation in forestplot
cwidth <- (upper - lower)
cwidth[cwidth <= 0 | is.na(cwidth)] <- min(cwidth[cwidth > 0])
textHeight <- convertUnit(grobHeight(textGrob("A", gp = do.call(gpar, txt_gp$label))), unitTo = "npc", valueOnly = TRUE)
info <- 1/cwidth * 0.75
info <- info/max(info, na.rm = TRUE)
if (any(textHeight * (nr + 0.5) * 1.5 < info))
info <- textHeight * (nr + 0.5) * 1.5 * info /
max(info, na.rm = TRUE) + textHeight * (nr + 0.5) * 1.5/4
info
# [1] NA 0.02402603 0.02857476 0.02594405 0.10882403
所以现在您应该得到与之前相同的尺寸
forestplot(tabletext,
boxsize = info,
mean=c(NA,tab$betas),
lower=c(NA,tab$lower),
upper=c(NA,tab$upper),
col=clrs, xlab=xlab, vertices = TRUE)