Dendrogram
Customer Segmentation Tree
Marketing customer clusters visualization
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(789)
segments = ['High Value', 'Frequent', 'New Users', 'At Risk', 'Dormant',
'Bargain Hunters', 'Premium', 'Loyal', 'Churned', 'Reactivated',
'VIP', 'Standard']
data = np.random.randn(len(segments), 5)
Z = linkage(data, method='complete')
fig, ax = plt.subplots(figsize=(12, 7), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
set_link_color_palette(['#4927F5', '#F527B0', '#27D3F5', '#6CF527'])
dn = dendrogram(Z, labels=segments, leaf_rotation=45, leaf_font_size=10,
color_threshold=5, above_threshold_color='#333333', ax=ax)
ax.axhline(y=5, color='#F527B0', linestyle='--', linewidth=1.5, alpha=0.8)
ax.set_title('Customer Segment Hierarchy', color='white', fontsize=14, fontweight='bold', pad=15)
ax.set_ylabel('Distance', color='#888888', fontsize=11)
ax.tick_params(axis='both', colors='white', labelsize=9)
for spine in ax.spines.values():
spine.set_color('#333333')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Dendrogram examples
☕