Dendrogram

Market Sector Hierarchy Light

Financial market sector clustering with bright neon palette

Output
Market Sector Hierarchy Light
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)

sectors = ['Technology', 'Healthcare', 'Financials', 'Energy', 'Materials',
           'Consumer Disc.', 'Consumer Staples', 'Industrials', 'Utilities',
           'Real Estate', 'Telecom', 'Basic Materials']

performance = np.random.rand(len(sectors), 6) * 100
Z = linkage(performance, method='complete')

fig, ax = plt.subplots(figsize=(13, 7), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

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

dn = dendrogram(Z, labels=sectors, leaf_rotation=35, leaf_font_size=11,
                color_threshold=0.6*max(Z[:,2]), above_threshold_color='#9ca3af', ax=ax)

ax.set_title('Market Sector Performance Clustering', fontsize=15, 
             color='#1f2937', fontweight='bold', pad=20)
ax.set_xlabel('Sector', fontsize=11, color='#374151')
ax.set_ylabel('Distance (Performance Similarity)', 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('#d1d5db')
ax.spines['bottom'].set_color('#d1d5db')
ax.yaxis.grid(True, color='#f9fafb', linewidth=0.8)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support