Returns width and height in inches scaled to the number of layout rows (studies, pooled / prediction diamonds, subgroup headers), plus footnote lines and axis / favours chrome. Full forests use about 0.28 inches per content row, 0.14 inches per footnote line, and ~2.3 inches of chrome, capped at 24 inches.
Arguments
- x
A
forestplot()result.- width
Target figure width in inches. When
NULL, uses a size derived from the number of rows and panels (including the width-to-height rule).- width_height
Target width / height ratio for the auto-recommended width. Default
NULLusesforestplot_default_width_height_ratio()(2).FALSEdisables widening.
Value
A list with elements width, height, aspect (width / height;
2 is a 2:1 landscape figure),
n_rows (content / layout rows), n_footnotes, n_chrome_in (axis +
favours band in inches), and formula (character description of the
height calculation).
Details
Height follows row count; the auto-recommended width (when width = NULL) is at least 2:1 width-to-height so exports stay landscape.
Passing an explicit width keeps that width unchanged (height still follows
content). Set width_height = FALSE to skip widening the auto width.
Use the returned sizes with png() / pdf() or knitr chunk options
(fig.width, fig.height). Compute dimensions before opening the device
or in a prior chunk, then pass them into the export / chunk options — the
active device height is what prevents row overlap / cut-off.
Examples
if (FALSE) { # \dontrun{
fp <- forestplot(fit)
dims <- forestplot_height(fp, width = 10)
png("forestplot.png", width = dims$width, height = dims$height,
units = "in", res = 300)
forestplot_draw(fp)
dev.off()
} # }
