3

I'm making a forest plot using the forestplot package in R. I have a lot of white space between the rows in my plot. How can I remove the space, or squeeze the rows together, to make a neater smaller graph? Many thanks.

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
user2363642
  • 727
  • 9
  • 26

1 Answers1

1

lineheight property in the forestplot() does the job

forestplot(your_table, lineheight='lines')

If You want to set a custom height, use lineheight=unit(1,'cm'), where the the expected value is float.

Sokolokki
  • 833
  • 1
  • 9
  • 19