""" From linkage matrix to dendrogram ================================= """ # %% # The :func:`~pdendro.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 :func:`scipy.cluster.hierarchy.linkage` function: import scipy Z = scipy.cluster.hierarchy.linkage(X) # %% # 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)