03 · One series across two CI columns
Each endpoint has two records with the same _plot_row and different
_ci_column values. The 30-day and 90-day intervals therefore share exactly
one vertical coordinate.
Run the example
from forestploter import read_forest_data
from forestploter.gallery_cases import plot_dual_ci_columns
df = read_forest_data("03_dual_ci_columns.xlsx", sheet_name="Forest")
result = plot_dual_ci_columns(df)
result.save("03_dual_ci_columns.png", dpi=300)
Plot function used by the gallery and tests
def plot_dual_ci_columns(df: ForestInput) -> ForestPlotResult:
"""Plot case 03: one series aligned across two CI columns."""
columns = (
ForestColumn("endpoint", "Endpoint", "text", 2.5),
ForestColumn("n", "N", "numeric", 0.6, "right"),
ForestColumn("ci_30d", "30-day risk ratio [95% CI]", "ci", 3.0, "center"),
ForestColumn("ci_90d", "90-day risk ratio [95% CI]", "ci", 3.0, "center"),
)
return forest(
df,
columns=columns,
ref_line=1.0,
xlim=(0.4, 1.6),
ticks_at=(0.4, 0.7, 1.0, 1.3, 1.6),
title="The same plot row aligned across two follow-up columns",
figure_width=12.0,
series_styles={"Observed": ForestSeriesStyle("Observed", "#1F4E79", marker="s")},
)