13 · Comprehensive two-column, three-series showcase
This synthetic example combines the package’s main input and rendering features in one figure. Each outcome is a bold header row containing its shared participant count and note; three programs appear below it as indented child rows. Every child has matching CI text in both the crude and adjusted panels. This workbook deliberately uses no merged cells. Lower- and upper-bound clipping are both visible. Both panels retain the no-effect reference line, while an additional target line appears in the adjusted panel only. Direction labels and both the series and line legends occupy the bottom region.
Rows use compact spacing, and CI text follows the conventional
0.68 [0.42, 0.92] form. Indented child labels, marker styling, and the
legend identify each series instead of repeating its name in every CI-text
cell.
Run the example
from forestploter import read_forest_data
from forestploter.gallery_cases import plot_comprehensive_showcase
df = read_forest_data("13_comprehensive_showcase.xlsx", sheet_name="Forest")
result = plot_comprehensive_showcase(df)
result.save("13_comprehensive_showcase.png", dpi=300)
Plot function used by the gallery and tests
def plot_comprehensive_showcase(df: ForestInput) -> ForestPlotResult:
"""Plot case 13: compact hierarchy with two CI columns and three series."""
columns = (
ForestColumn("label", "Outcome / program", "text", 2.05),
ForestColumn("participants", "N", "numeric", 0.55, "right"),
ForestColumn("ci_crude", "Crude model\nrisk ratio", "ci", 2.65, "center"),
ForestColumn(
"crude_ci_text",
"Crude RR [95% CI]",
"numeric",
1.45,
"right",
),
ForestColumn("ci_adjusted", "Adjusted model\nrisk ratio", "ci", 2.65, "center"),
ForestColumn(
"adjusted_ci_text",
"Adjusted RR [95% CI]",
"numeric",
1.45,
"right",
),
ForestColumn("note", "Outcome-level note", "text", 1.75),
)
styles = {
"Integrated care": ForestSeriesStyle("Integrated care", "#332288", marker="s"),
"Digital support": ForestSeriesStyle("Digital support", "#CC6677", marker="o"),
"Usual care": ForestSeriesStyle("Usual care", "#117733", marker="^"),
}
return forest(
df,
columns=columns,
ref_line=1.0,
ideal_line=0.75,
ideal_line_columns=("ci_adjusted",),
xlim=(0.5, 1.5),
ticks_at=(0.5, 0.75, 1.0, 1.25, 1.5),
arrow_lab=("Favours integrated care", "Favours usual care"),
title="Comprehensive showcase: three programs across two models",
figure_width=16.5,
row_height=0.16,
series_styles=styles,
legend=ForestLegendSpec(location="bottom", ncol=3),
reference_legend=ForestReferenceLegendSpec(
reference_label="No effect (RR = 1)",
ideal_label="Target (RR = 0.75; adjusted panel only)",
location="bottom",
ncol=2,
),
theme=ForestTheme(
base_font_size=8.2,
header_fill="#ECE8F3",
alternate_fill="#FAF9FC",
group_fill="#F3EFF7",
grid_color="#D9D2E3",
reference_color="#45404A",
ideal_color="#7A5542",
),
table_layout=ForestTableLayoutSpec(
auto_width=True,
auto_wrap_headers=True,
max_header_lines=3,
max_figure_width=18.5,
),
)