Heatmap
Survey Response Analysis
Likert scale response distribution by demographic
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)
# Survey questions and demographics
questions = ['Product Quality', 'Customer Service', 'Value for Money',
'Ease of Use', 'Would Recommend', 'Overall Satisfaction']
demographics = ['18-24', '25-34', '35-44', '45-54', '55-64', '65+']
# Generate response data (1-5 Likert scale averaged)
data = np.random.uniform(3.0, 4.8, (len(demographics), len(questions)))
# Younger more satisfied with ease of use
data[0:2, 3] += 0.3
# Older more satisfied with service
data[4:, 1] += 0.2
df = pd.DataFrame(data, index=demographics, columns=questions)
# NEON blue-green for positive scale
neon_pos = LinearSegmentedColormap.from_list('neon_pos', ['#f3f4f6', '#27D3F5', '#6CF527'])
fig, ax = plt.subplots(figsize=(10, 5), facecolor='#ffffff')
ax.set_facecolor('#ffffff')
sns.heatmap(df, cmap=neon_pos, annot=True, fmt='.2f', linewidths=2, linecolor='#ffffff',
vmin=3, vmax=5, annot_kws={'size': 11, 'fontweight': '500'},
cbar_kws={'shrink': 0.8, 'label': 'Average Rating (1-5)'}, ax=ax)
ax.set_title('Customer Satisfaction by Age Group', color='#1f2937', fontsize=14, fontweight='bold', pad=15)
ax.set_xlabel('Survey Question', color='#1f2937', fontsize=11)
ax.set_ylabel('Age Group', color='#1f2937', fontsize=11)
ax.tick_params(colors='#374151', labelsize=10)
ax.set_xticklabels(ax.get_xticklabels(), rotation=30, ha='right')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Heatmaps & Density
More Heatmap examples
☕