Dendrogram
Horizontal Dendrogram Light Theme
Horizontal layout dendrogram with neon accents on white
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy.cluster.hierarchy import dendrogram, linkage, set_link_color_palette
np.random.seed(654)
items = ['Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta',
'Theta', 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', 'Omicron']
data = np.random.rand(len(items), 5) * 80
Z = linkage(data, method='ward')
fig, ax = plt.subplots(figsize=(10, 9), facecolor='#ffffff')
ax.set_facecolor('#ffffff')
set_link_color_palette(['#F5276C', '#27D3F5', '#6CF527', '#F5B027', '#5314E6'])
dn = dendrogram(Z, labels=items, orientation='right', leaf_font_size=11,
color_threshold=0.6*max(Z[:,2]), above_threshold_color='#9ca3af', ax=ax)
ax.set_title('Hierarchical Cluster Analysis', fontsize=15,
color='#1f2937', fontweight='bold', pad=15)
ax.set_xlabel('Distance', fontsize=11, color='#374151')
ax.set_ylabel('Items', fontsize=11, color='#374151')
ax.tick_params(axis='both', colors='#374151', labelsize=10)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#e5e7eb')
ax.spines['bottom'].set_color('#e5e7eb')
ax.xaxis.grid(True, color='#f3f4f6', linewidth=0.5)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Dendrogram examples
☕