Dendrogram

Programming Language Family Tree Light

Programming language similarity dendrogram with light theme

Output
Programming Language Family Tree 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(789)

languages = ['Python', 'Ruby', 'JavaScript', 'TypeScript', 'Java', 'Kotlin',
             'C++', 'C', 'Rust', 'Go', 'Swift', 'Objective-C', 'PHP', 'Perl']

features = np.random.rand(len(languages), 8) * 10
Z = linkage(features, method='ward')

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

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

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

ax.set_title('Programming Language Similarity Clustering', fontsize=15, 
             color='#1f2937', fontweight='bold', pad=18)
ax.set_xlabel('Language', fontsize=11, color='#374151')
ax.set_ylabel('Feature Distance', 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')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support