3

I'd add two arrows to a forest plot for a paper going to a journal. Here is a demo plot from metafor::forest:

require(metafor)
data(dat.bcg)
res <- rma(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg,
           slab=paste(author, year, sep=", "))
forest(res, cex=.8, order=order(dat.bcg$ablat), addfit=F)

what I want is to add two arrows along x axis such like(in red box): enter image description here

Does somebody know how to do it?

David Z
  • 6,641
  • 11
  • 50
  • 101

1 Answers1

3

One idea is to use layout to divide your plot in 2 parts and replace the x axis label by a new plot.

enter image description here

## define the layout matrix  
## 2 rows and 3 columns , the rectangle will be in the cell(2,2)
layout(matrix(c(1,1,1,0,2,0), 2, 3, byrow = TRUE),
       heights=c(3,1),widths=c(1,2,1))
## define the margin since the default ones are usually not enough
par(mar = rep(2, 4))

## your plot here 
data(dat.bcg)
res <- rma(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg,
           slab=paste(author, year, sep=", "))
forest(res, cex=.8, order=order(dat.bcg$ablat), addfit=F,xlab='')

## here all the job 
x <- y <- 2:8 
## dummy plot to define scales
plot(x,y,type='n',axes=F,xlab='',ylab='')
## rectangle
rect(2,4,8,8,border='red')
## arrows
arrows(5.5,6,7,6)
arrows(4.5,6,3,6)
text(6,6,'A better',adj=c(0,1.5),col='blue')
text(3.5,6,'B better',adj=c(0,1.5),col='green')
## x label
text(5,3,'Risk Difference',cex=2)
agstudy
  • 119,832
  • 17
  • 199
  • 261
  • Thanks, @agstudy. The red rectangle is not part of the plot, just a indicator:D. – David Z Nov 03 '14 at 19:29
  • 1
    @DavidZ :) I like it ! I will keep it in my answer! – agstudy Nov 03 '14 at 19:31
  • @agstudy is there a way to add this to a forestplot using the R forestplot package? I have posted a question about this https://stackoverflow.com/questions/61765729/add-arrows-to-forestplot-r?noredirect=1&lq=1 – sar May 13 '20 at 14:40