From linkage matrix to dendrogramΒΆ

The attach_dendrogram() function generates components of a dendrogram from a linkage matrix and attaches them to a figure. Let us assume that we have the following data points:

X = [[0.0], [1.0], [3.0], [6.0]]

The linkage matrix can be computed using the scipy.cluster.hierarchy.linkage() function:

Then, a dendrogram can be drawn as follows:

import plotly.graph_objects as go
import plotly.io as pio

from pdendro import attach_dendrogram

fig = go.Figure()
attach_dendrogram(fig, Z)
pio.show(fig)

Gallery generated by Sphinx-Gallery