Clustermap

Automotive Performance Matrix

Vehicle specifications clustering with cylinder grouping

Output
Automotive Performance Matrix
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
from matplotlib.colors import LinearSegmentedColormap

np.random.seed(42)

# Simulated automotive data
cars = ['Model_' + chr(65+i) for i in range(20)]
metrics = ['MPG', 'HP', 'Weight', 'Accel', 'Disp', 'Torque', 'Price', 'Range']

data = np.random.rand(20, 8)
# Add structure
data[:7, [1, 4, 5]] += 0.5  # High performance cars
data[7:14, [0, 7]] += 0.5   # Efficient cars
data[14:, [2, 6]] += 0.5    # Heavy/expensive cars

df = pd.DataFrame(data, index=cars, columns=metrics)

# Cylinder groups
cylinders = [8]*7 + [4]*7 + [6]*6
cyl_palette = {4: '#6CF527', 6: '#F5B027', 8: '#F5276C'}
row_colors = pd.Series(cylinders, index=cars).map(cyl_palette)

# NEON blue-pink colormap
neon_cmap = LinearSegmentedColormap.from_list('neon_bp', ['#0a0a0f', '#4927F5', '#F5276C', '#F5B027'])

g = sns.clustermap(df, cmap=neon_cmap, row_colors=row_colors,
                   standard_scale=1, method='average',
                   linewidths=0.3, linecolor='#1a1a2e',
                   figsize=(8, 7), dendrogram_ratio=(0.12, 0.12),
                   cbar_pos=(0.01, 0.08, 0.008, 0.12),
                   tree_kws={'linewidths': 1.5, 'colors': '#27D3F5'})

g.fig.patch.set_facecolor('#0a0a0f')
g.ax_heatmap.set_facecolor('#0a0a0f')
g.ax_heatmap.tick_params(colors='white', labelsize=8)

for ax in [g.ax_row_dendrogram, g.ax_col_dendrogram]:
    ax.set_facecolor('#0a0a0f')

g.fig.suptitle('Automotive Performance Clustering', color='white', fontsize=14, fontweight='bold', y=1.02)


plt.show()
Library

Matplotlib

Category

Heatmaps & Density

Did this help you?

Support PyLucid to keep it free & growing

Support