2

metafor::forest prepares for headings etc by creating a horizontal line and three blank rows in the top of the plot. Is there a way to avoid that?

I have too cases where this poses a problem:

  • For a simple forest plot, one header row is sufficient. I have to manually add a title just above the horizontal line using text rather than title and then crop the image afterwards.
  • I want to create a forest plot of pure summary estimates using addpoly. I have to crop the top of the image because of the spacing and horizontal line
Jonas Lindeløv
  • 5,442
  • 6
  • 31
  • 54

1 Answers1

3

To get rid of some of that extra space at the top, you can use:

par(mar=c(5,4,0,2))

before you create the plot. The crucial one is the third value.

The horizontal line is hardcoded. You could just consider drawing a white line on top of it that will hide it (yes, a bit hackish ...). An example:

library(metafor)
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
res <- rma(yi, vi, data=dat)
par(mar=c(5,4,0,2))
forest(res)
abline(h=res$k+1, lwd=2, col="white")

If you need to squeeze out even more space, you could try this:

forest(res, refline=NA, ylim=c(-1.5, res$k+0.5))
abline(h=res$k-1.5, lwd=2, col="white")
Wolfgang
  • 2,810
  • 2
  • 15
  • 29