Dendrogram

Neon Cluster Dendrogram

Hierarchical clustering with neon color palette

Output
Neon Cluster Dendrogram
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy.cluster.hierarchy import dendrogram, linkage

np.random.seed(42)

# Generate sample data
n_samples = 20
data = np.random.randn(n_samples, 5)
labels = [f'Sample_{i+1}' for i in range(n_samples)]

Z = linkage(data, method='ward')

fig, ax = plt.subplots(figsize=(12, 7), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

# Custom neon colors
from scipy.cluster.hierarchy import set_link_color_palette
set_link_color_palette(['#27D3F5', '#6CF527', '#F5B027', '#F5276C', '#4927F5'])

dn = dendrogram(Z, labels=labels, leaf_rotation=45, leaf_font_size=9,
                color_threshold=0.7*max(Z[:,2]), above_threshold_color='#444444',
                ax=ax)

ax.set_title('Hierarchical Clustering Analysis', color='white', fontsize=14, fontweight='bold', pad=15)
ax.set_xlabel('Samples', color='#888888', fontsize=11)
ax.set_ylabel('Distance', color='#888888', fontsize=11)

ax.tick_params(axis='both', colors='white', labelsize=9)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#333333')
ax.spines['bottom'].set_color('#333333')

for label in ax.get_xticklabels():
    label.set_color('white')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support