Note
Go to the end to download the full example code.
Inspecting nodeΒΆ
Information about a node is displayed in its tooltip. There are three items: id, distance,
and size.
The id is the node ID. In the following code, the id of a leaf node corresponding
to X[i] is i and that of a branch node corresponding to Z[i] is i+n.
The distance is the distance between child nodes. It is zero for leaf nodes. In the following
code, the distance of a branch node corresponding to Z[i] is its y-coordinate, or
Z[i, 2].
The size is the number of descendant leaf nodes. It is one for leaf nodes. In the following
code, the size of a branch node corresponding to Z[i] is Z[i, 3].
import plotly.graph_objects as go
import plotly.io as pio
import scipy
from pdendro import attach_dendrogram
X = [[0.0], [1.0], [3.0], [6.0]]
Z = scipy.cluster.hierarchy.linkage(X)
fig = go.Figure()
attach_dendrogram(fig, Z)
pio.show(fig)