Heatmap
Customer Segmentation Matrix
RFM analysis heatmap for customer segments
Output
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)
# RFM-like customer data
segments = ['Champions', 'Loyal', 'Potential', 'New', 'At Risk', 'Lost']
metrics = ['Frequency', 'Monetary', 'Recency', 'Engagement', 'LTV', 'Satisfaction']
# Segment profiles
data = np.array([
[0.95, 0.90, 0.95, 0.88, 0.92, 0.90], # Champions
[0.80, 0.75, 0.85, 0.72, 0.78, 0.82], # Loyal
[0.55, 0.50, 0.70, 0.60, 0.55, 0.65], # Potential
[0.30, 0.25, 0.90, 0.45, 0.20, 0.50], # New
[0.25, 0.35, 0.20, 0.30, 0.40, 0.35], # At Risk
[0.10, 0.15, 0.05, 0.08, 0.12, 0.15], # Lost
])
df = pd.DataFrame(data, index=segments, columns=metrics)
# NEON coral colormap
neon_coral = LinearSegmentedColormap.from_list('neon_coral', ['#ffffff', '#F5B027', '#F5276C', '#9C2007'])
fig, ax = plt.subplots(figsize=(9, 6), facecolor='#ffffff')
ax.set_facecolor('#ffffff')
sns.heatmap(df, cmap=neon_coral, annot=True, fmt='.0%', linewidths=2, linecolor='#ffffff',
vmin=0, vmax=1, annot_kws={'size': 11, 'fontweight': '600'},
cbar_kws={'shrink': 0.8, 'label': 'Score'}, ax=ax)
ax.set_title('Customer Segment Analysis', color='#1f2937', fontsize=14, fontweight='bold', pad=15)
ax.tick_params(colors='#374151', labelsize=10)
ax.set_xticklabels(ax.get_xticklabels(), rotation=45, ha='right')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Heatmaps & Density
More Heatmap examples
☕