我正在使用R中的forestplot软件包制作森林图。在我的图行之间有很多空白。如何删除空间或将行挤压在一起以制作更整洁的小图?非常感谢。

library(forestplot)
main5 <-
  structure(list(
    mean  = c(NA, NA,  0.80, 0.90, 0.7, 1.2),
    lower = c(NA, NA,  0.70, 0.50, 0.59, 1.11),
    upper = c(NA, NA,  1.02, 1.25, 1.04, 1.94)),
    .Names = c("mean", "lower", "upper"),
    row.names = c(NA, -6L),
    class = "data.frame")

tabletext5<-cbind(
  c("", "Analysis", "Outcome: X",  Outcome: Y", "Outcome: Z", "Outcome: xx"),
  c("", "A
          time",  "115987.8", "117604.4", "118518.6","115493.2"),
  c("", "A
          Outcomes", "813", "51", "715", "2114"),
  c("", "B
          time",  "114516.2", "118728.5", "117896.2","119096.3"),
  c("", "B
          Outcomes",  "1199", "71", "911","1109"),
  c("", "HR", "0.8", "0.9", "0.7", "1.2"),
  c("", "99% CI", "0.70, 1.02", "0.50, 1.25", "0.59, 1.04", "1.11, 1.94"))

forestplot(tabletext5,
           main5,new_page = TRUE,
           hrzl_lines=list("3" = gpar(lwd=1, col="#444444")),
           is.summary=c(TRUE, TRUE, rep(FALSE, 5)),
           txt_gp = fpTxtGp(label=gpar(cex=0.7)
           ),
           boxsize=0.3,
           xlog=T,
           graphwidth = unit(9, "cm"),
           graphheight = unit(6, "cm"),
           clip= c(0.5, 3.0),
           xticks=c(0.5, 1.0, 1.5, 2.0, 2.5),
           xlab="   B worse                                                    A worse                                                        ",
           fs.xlab=60,
           col=fpColors(box="#7570B3",line="#7570B3"))  ##have picked the blue colour from the "dark2 palette

最佳答案

lineheight中的forestplot()属性可以完成工作
forestplot(your_table, lineheight='lines')
如果要设置自定义高度,请使用lineheight=unit(1,'cm'),其中期望值为float

07-24 09:51