Correlogram
Retail Customer Behavior Matrix
Marketing analytics correlogram of consumer behavior by segment
Output
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
np.random.seed(456)
n = 180
segments = np.random.choice(['Premium', 'Standard', 'Budget'], n)
data = {
'Spend ($)': np.where(segments == 'Premium', np.random.normal(500, 100, n),
np.where(segments == 'Standard', np.random.normal(200, 50, n), np.random.normal(50, 20, n))),
'Frequency': np.where(segments == 'Premium', np.random.normal(12, 3, n),
np.where(segments == 'Standard', np.random.normal(6, 2, n), np.random.normal(2, 1, n))),
'Tenure (mo)': np.where(segments == 'Premium', np.random.normal(36, 12, n),
np.where(segments == 'Standard', np.random.normal(18, 8, n), np.random.normal(6, 3, n))),
'NPS': np.where(segments == 'Premium', np.random.normal(65, 15, n),
np.where(segments == 'Standard', np.random.normal(40, 20, n), np.random.normal(20, 25, n))),
'Segment': segments
}
df = pd.DataFrame(data)
sns.set_style("whitegrid", {'axes.facecolor': '#ffffff', 'figure.facecolor': '#ffffff', 'grid.color': '#eeeeee'})
palette = {'Premium': '#5314E6', 'Standard': '#27D3F5', 'Budget': '#F5B027'}
g = sns.pairplot(
df,
hue='Segment',
palette=palette,
height=2,
kind='scatter',
diag_kind='kde',
markers=['D', 'o', 's'],
plot_kws={'alpha': 0.7, 's': 55, 'edgecolor': 'white', 'linewidths': 0.6},
diag_kws={'alpha': 0.5, 'linewidth': 2.5, 'fill': True}
)
g.fig.set_facecolor('#ffffff')
for ax in g.axes.flat:
if ax:
ax.set_facecolor('#ffffff')
for spine in ax.spines.values():
spine.set_color('#dddddd')
ax.tick_params(colors='#666666')
ax.xaxis.label.set_color('#333333')
ax.yaxis.label.set_color('#333333')
g.fig.suptitle('Customer Behavior Segmentation', fontsize=14, fontweight='bold', color='#1a1a1a', y=1.02)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Correlogram examples
☕