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

Sankey Diagram

Signature

sp.sankey(title, labels, edges_i, edges_j, edges_w, *, variant="basic", **kwargs) -> Chart

Aliases: sp.sankey, sp.sankeys, sp.sankey_chart, sp.sankey_diagram, sp.flow_chart

Description

Sankey diagrams visualize flows between nodes. Node widths and link widths are proportional to flow volumes. Edges are defined by source indices (edges_i), target indices (edges_j), and weights (edges_w). Nodes are laid out in columns by BFS depth.

Variants

Data

labels (list[str]) — Node names. edges_i (list[int]) — Source node indices. edges_j (list[int]) — Target node indices. edges_w (list[float]) — Flow weights. width / height (int) — Chart dimensions.

Parameters

Themes

Returns

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

Parameters

Standard bezier ribbon links

Variant "basic"Aliases basic / default / classicReturns Chart
Preview

Increased node spacing

Variant "gapped"Aliases gapped / spaced / separatedReturns Chart
Preview

Wider nodes and ribbons

Variant "ribbon"Aliases ribbon / wide / thickReturns Chart
Preview

Thin outline style

Variant "minimal"Aliases minimal / thin / outlineReturns Chart
Preview

Reorders nodes within each depth column by descending total throughput, so the dominant flows cluster together instead of sitting in input order — makes it easy to spot which nodes carry the most volume.

Variant "sorted"Aliases sorted / reordered / by_flow / ranked
Preview

Every source starts as its own thin row on the left and every ribbon is pulled through a single fixed pinch point before fanning back out into a radial arc of target wedges on the right — each wedge's angular width is proportional to the square root of its total incoming flow (a mild compression so one outlier target can't visually swallow the rest of the arc). Built for bipartite many-sources-to-few-categories data, e.g. foods flowing into the nutrients they're rich in.

Variant "hourglass"Aliases hourglass / radiant_flow / nutrient_flow / braided / flow_bloom
Preview

Sources are laid out as a dot-matrix grid instead of a node list — one marker per record, sized by its own weight and colored by the category it ultimately flows to — with thin low-opacity ribbons converging on a handful of large target circles sized by total share and labeled with their percentage of the whole. Built for record-level "big data" flows: many individual rows collapsing into a few outcome buckets.

Variant "matrix"Aliases matrix / mosaic / dot_matrix / grid_flow / big_data
Preview

A single source radiates to every target around a full circle instead of two flat columns — each target sits at its own angle with a short pill sized and colored by weight (a continuous colorscale, not a fixed palette), connected back to the hub by a thin bowed spoke. Built for one-to-many schedules where each target also carries its own label, e.g. a departure board: one hub airport, every outbound flight arranged around the dial with its destination, time and duration.

Variant "beacon"Aliases beacon / flight_radar / route_wheel / departure_board / hub_wheel
Preview