Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Stackplot — Stacked Area / Streamgraph

Signature

sp.stackplot(title, x_labels, series, *, variant="basic", series_names=None, **kwargs) -> Chart

Aliases: sp.stackplot, sp.stack_plot, sp.stacked_area, sp.build_stackplot

Description

sp.stackplot() draws multiple series as cumulatively stacked areas over a shared x-axis — reuses the exact same x_labels/series/series_names input shape as multiline(), so any dataset already used with multiline() works unchanged. Negative values are clamped to 0 before stacking (a stack has no meaningful negative contribution).

Variants

Data

x_labels (list[str]) — Shared x-axis point labels. series (list[list[float]]) — One list of values per series, same length as x_labels. series_names (list[str]) — Legend label per series.

Parameters

Themes

Returns

Chart — object with .html property and .show() method.

Traditional zero-baseline stacking, each series added on top of the previous one's cumulative total.

Variant "basic"Aliases basic / default / classic / stacked
Preview

Centered ("silhouette") baseline — at every x-point the stack is centered around zero (`baseline = -total/2`) instead of starting at zero, giving the flowing ThemeRiver look.

Variant "streamgraph"Aliases streamgraph / stream / silhouette / themeriver
Preview

100%-stacked — every series is divided by the x-point's total before stacking, so the top of the stack is always 1.0. Shows share of total over time instead of absolute magnitude.

Variant "normalized"Aliases normalized / percent / hundred_percent / share
Preview

Polar-wrapped stacking — each x-point becomes an angle around a circle instead of a position along an axis, and the cumulative bands grow outward as concentric rings from a small central hole. A genuinely different read on the same stacked data: total magnitude becomes an overall silhouette size, and each series' share becomes a colored band thickness at that angle.

Variant "radial"Aliases radial / polar / radar_stack / circular
Preview

Cartesian stacking rendered as smooth, glowing ribbons: quadratic-bezier-smoothed band edges, a top-to-bottom depth gradient per series, and a soft drop-shadow separating each layer — a more atmospheric, editorial look than the sharp-edged basic stack.

Variant "ribbon"Aliases ribbon / glow / smooth / flow
Preview