09 · Deep hierarchy and many rows
Several regions, two indentation levels, subtotals, spacer rows, and thirty visual rows exercise vertical scaling and hierarchy readability.
Run the example
from forestploter import read_forest_data
from forestploter.gallery_cases import plot_deep_hierarchy_many_rows
df = read_forest_data("09_deep_hierarchy_many_rows.xlsx", sheet_name="Forest")
result = plot_deep_hierarchy_many_rows(df)
result.save("09_deep_hierarchy_many_rows.png", dpi=300)
Plot function used by the gallery and tests
def plot_deep_hierarchy_many_rows(df: ForestInput) -> ForestPlotResult:
"""Plot case 09: deep indentation and many rows."""
columns = (
ForestColumn("label", "Region / subgroup", "text", 3.0),
ForestColumn("n", "N", "numeric", 0.7, "right"),
ForestColumn("effect_display", "Mean difference [95% CI]", "numeric", 2.0, "right"),
ForestColumn("ci", "Regional treatment effect", "ci", 3.5, "center"),
)
return forest(
df,
columns=columns,
ref_line=0.0,
xlim=(-1.0, 1.0),
ticks_at=(-1.0, -0.5, 0.0, 0.5, 1.0),
arrow_lab=("Favours treatment", "Favours control"),
title="Deep hierarchy and many-row layout stress test",
figure_width=11.8,
row_height=0.31,
)