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.

Parameters

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

Reimagines circle packing as a grouped commit swarm: parents becomes any grouping bucket instead of a tree parent, and every leaf is one real commit — a genuine front-chain circle-packing pass clusters each group's commits into its own organic, non-overlapping blob, auto-arranged in a grid. Circle size encodes lines changed, fill color encodes the commit type (feat / fix / docs / refactor / chore / style / perf / test), and automated commits render as hexagons instead of circles. Compose several single-group swarms with the canvas frieze()/timeline() method to string them along a real chronology instead. The bundled demo plots SeraPlot's own real git history.

Variant "swarm"Aliases swarm / commit_swarm / commit_history / dev_swarm / orca
Preview

Turns circle packing into a two-axis category grid: parents and categories become any pair of categorical fields (say, region × orbit class), and every cell runs its own real front-chain circle-packing pass, scaled to how much of the data actually lands there — a busy combination visibly earns more room instead of just cramming more dots into the same box. Circle size encodes a magnitude (values), fill color encodes one category (categories2), and marker shape (circle / star / diamond / triangle / …) encodes a second, independent one (symbols) — three readable encodings stacked on top of the two axes. An optional continuous field (color_values, e.g. a launch year) fades older points and keeps recent ones at full strength. The bundled demo plots a synthetic satellite catalog.

Variant "matrix"Aliases matrix / grid / swarm_matrix / category_grid / space_wars
Preview