05 · Long text and multilingual layout
Long headers, long subgroup labels, Chinese/English content, automatic header wrapping, and automatic Figure-width growth are exercised together.
Run the example
from forestploter import read_forest_data
from forestploter.gallery_cases import plot_long_layout
df = read_forest_data("05_long_layout.xlsx", sheet_name="Forest")
result = plot_long_layout(df)
result.save("05_long_layout.png", dpi=300)
Plot function used by the gallery and tests
def plot_long_layout(df: ForestInput) -> ForestPlotResult:
"""Plot case 05: long labels, multilingual text, and auto layout."""
columns = (
ForestColumn("subgroup", "Prespecified participant subgroup", "text", 2.8),
ForestColumn("region", "Geographic recruitment region", "text", 1.1),
ForestColumn("participants", "Participants analyzed", "numeric", 0.8, "right"),
ForestColumn(
"effect_display", "Adjusted mean difference [95% CI]", "numeric", 1.8, "right"
),
ForestColumn("ci", "Adjusted treatment effect [95% CI]", "ci", 2.8, "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="Layout stress test: long labels and multilingual text",
figure_width=7.5,
row_height=0.42,
theme=ForestTheme(base_font_size=8.25),
table_layout=ForestTableLayoutSpec(
auto_width=True,
auto_wrap_headers=True,
column_padding_pt=7.0,
edge_padding_pt=6.0,
max_header_lines=3,
max_figure_width=16.0,
),
)