how to draw dendrogram in python

Solutions on MaxInterview for how to draw dendrogram in python by the best coders in the world

showing results for - "how to draw dendrogram in python"
Tom
03 Jan 2020
1>>> ytdist = np.array([662., 877., 255., 412., 996., 295., 468., 268.,
2...                    400., 754., 564., 138., 219., 869., 669.])
3>>> Z = hierarchy.linkage(ytdist, 'single')
4>>> plt.figure()
5>>> dn = hierarchy.dendrogram(Z)
6
Paolo
10 Jan 2018
1>>> from scipy.cluster import hierarchy
2>>> import matplotlib.pyplot as plt
3
Maya
23 Jul 2017
1>>> hierarchy.set_link_color_palette(['m', 'c', 'y', 'k'])
2>>> fig, axes = plt.subplots(1, 2, figsize=(8, 3))
3>>> dn1 = hierarchy.dendrogram(Z, ax=axes[0], above_threshold_color='y',
4...                            orientation='top')
5>>> dn2 = hierarchy.dendrogram(Z, ax=axes[1],
6...                            above_threshold_color='#bcbddc',
7...                            orientation='right')
8>>> hierarchy.set_link_color_palette(None)  # reset to default after use
9>>> plt.show()
10