Dendrogram

Horizontal Dendrogram Dark

Left-oriented dendrogram with neon styling

Output
Horizontal Dendrogram Dark
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy.cluster.hierarchy import dendrogram, linkage, set_link_color_palette

np.random.seed(456)

categories = ['Electronics', 'Clothing', 'Food', 'Sports', 'Books', 
              'Home', 'Beauty', 'Toys', 'Auto', 'Garden']
data = np.random.randn(len(categories), 6)

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

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

set_link_color_palette(['#27D3F5', '#6CF527', '#F5B027', '#F5276C'])

dn = dendrogram(Z, labels=categories, orientation='left', leaf_font_size=11,
                color_threshold=4, above_threshold_color='#444444', ax=ax)

ax.set_title('Product Category Clustering', color='white', fontsize=14, fontweight='bold', pad=15)
ax.set_xlabel('Distance', color='#888888', fontsize=11)

ax.tick_params(axis='both', colors='white', labelsize=10)
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

Did this help you?

Support PyLucid to keep it free & growing

Support