'metafor: use of annosym argument in addpoly()

I draw a forest plot with non-default annosym values:

res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure = 'OR', method='DL',
       slab=paste(author, year))


forest(res, 
   annosym=c(' (','; ',')'),
   ylim=c(-2,16)
)

And try to add some sub-analysis results with the same annosym specification:

dat.bcg.rand <- dat.bcg[dat.bcg$alloc=='random',]

res.rand <- rma.uni(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg.rand, measure = 'OR', method='DL', 
                            slab=paste(author, year))

addpoly(res.rand, mlab='Random alloc.',atransf=exp, annosym=c(' (','; ',')'))

to see a warning:

Warning messages:
1: In text.default(...) : "annosym" is not a graphical parameter
2: In segments(...) : "annosym" is not a graphical parameter
3: In segments(...) : "annosym" is not a graphical parameter
4: In segments(...) : "annosym" is not a graphical parameter
5: In polygon(...) : "annosym" is not a graphical parameter
6: In text.default(...) : "annosym" is not a graphical parameter

and a plot that mixes two annosym specifications:

enter image description here

Do you have any workarounds for this? I really, really need to change default annosyms in addpoly().



Solution 1:[1]

No idea why I forgot to implement annosym in addpoly.default() and addpoly.rma() but this has now been added. So if you grab the 'development' version of metafor as described here:

https://github.com/wviechtb/metafor#installation

then it should work.

One other issue if you add polygons like this: The alignment is off because less space is needed for the annotations corresponding to that last polygon. You can use:

addpoly(res.rand, mlab='Random alloc.', atransf=exp, annosym=c(' (','; ',')'), width=c(5,5,5))

(or just width=5) to fix this (note that -0.75 consists of 5 characters). The alignment will still be slightly off because by default a non-fixed-width font is used for the text. If you combine this with fonts="mono" in both forest() and addpoly(), then the alignment will be right. You can also use other fonts than the default fixed-width font to make this look nicer and/or only a fixed-width font for the annotations (fonts can take two values).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wolfgang