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

Dendrogram

Signature

sp.dendrogram(title, labels, *, matrix=None, parents=None, clusters=3, variant="vertical", **kwargs) -> Chart

Aliases: sp.dendrogram, sp.dendro, sp.tree, sp.tree_diagram, sp.hierarchy, sp.hierarchical

Description

Dendrograms display hierarchical tree structures using right-angle elbow connectors (vertical/horizontal) or smooth bezier curves (elegant) or a radial circular layout. Pass matrix -- one row of numeric coordinates per label -- for a genuine average-linkage agglomerative clustering with real merge heights (matching hclust/scipy), including automatic coloring of the top clusters groups with the trunk above the cut shown in neutral gray. Without matrix, parents describes a plain hand-specified hierarchy (each entry names its parent's label, empty string for a root) with no real distance semantics.

Variants

Data

labels (list[str]) — Node names. parents (list[str]) — Parent name per node ("" = root). width / height (int) — Chart dimensions.

Parameters

Themes

Returns

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

Root at top, leaves at bottom (elbow connectors)

Variant "vertical"Aliases vertical / top / default / classic
Preview

Root at left, leaves at right

Variant "horizontal"Aliases horizontal / left / h
Preview

Circular radial tree layout

Variant "radial"Aliases radial / circular / polar
Preview

Tighter spacing, smaller font

Variant "compact"Aliases compact / dense / tight
Preview

Smooth cubic bezier curves

Variant "elegant"Aliases elegant / smooth / rounded
Preview

Connects parent to child with a single straight diagonal line — a third connector style alongside the right-angle elbows (vertical/horizontal) and smooth beziers (elegant).

Variant "triangular"Aliases triangular / diagonal / straight / angular
Preview