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

Circle Packing

Signature

sp.circle_pack(title, labels, parents, values, *, variant="basic", **kwargs) -> Chart

Aliases: sp.circle_pack, sp.circle_packing, sp.pack, sp.bubble_pack

Description

Circle packing represents hierarchical data as nested circles, where the area of each circle is proportional to its value. Parent–child relationships are defined by the parents list (empty string = root node).

Variants

Data

labels (list[str]) — Node names. parents (list[str]) — Parent name for each node ("" = root). values (list[float]) — Size of each leaf node. width / height (int) — Chart dimensions.

Parameters

Themes

Returns

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

Filled nested circles with depth-based opacity

Variant "basic"Aliases basic / default / nested
Preview

Single-level bubble layout (no nesting)

Variant "flat"Aliases flat / single
Preview

Stroke-only circles

Variant "outlined"Aliases outlined / stroke / border
Preview

Runs a real greedy circle-packing layout: each circle is placed tangent to the best pair of already-placed circles (falling back to a spiral search when no tangent placement fits), producing a genuinely nested, non-overlapping bubble cluster instead of the grid-like flat layout.

Variant "bubble"Aliases bubble / packed
Preview

Fills only the leaf circles with color and shrinks every container circle to a faint dashed outline — declutters the hierarchy chrome so attention goes straight to the actual data points instead of the grouping structure.

Variant "leaf_focus"Aliases leaf_focus / leaves / leaves_only / focus
Preview