Area Chart

Customer Satisfaction Trend

NPS score evolution with confidence bands

Output
Customer Satisfaction Trend
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)
months = np.arange(1, 25)  # 2 years

# NPS improving trend
nps = 35 + 0.8*months + np.random.normal(0, 3, len(months))
std = 8 - 0.15*months + np.random.normal(0, 0.5, len(months))
std = np.clip(std, 3, 10)

fig, ax = plt.subplots(figsize=(10, 6), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

ax.fill_between(months, nps - std*2, nps + std*2, alpha=0.15, color='#4927F5')
ax.fill_between(months, nps - std, nps + std, alpha=0.3, color='#4927F5')
ax.plot(months, nps, color='#4927F5', linewidth=2.5, label='NPS Score')

# Target line
ax.axhline(50, color='#6CF527', linewidth=2, linestyle='--', label='Target NPS')

# Milestone markers
ax.scatter([12, 24], [nps[11], nps[23]], color='#F5276C', s=100, zorder=5, edgecolors='white', linewidth=2)
ax.annotate(f'Y1: {nps[11]:.0f}', (12, nps[11]), xytext=(10, 10), textcoords='offset points', color='#1f2937', fontsize=10)
ax.annotate(f'Y2: {nps[23]:.0f}', (24, nps[23]), xytext=(10, 10), textcoords='offset points', color='#1f2937', fontsize=10)

ax.set_xlabel('Month', color='#1f2937', fontsize=11)
ax.set_ylabel('Net Promoter Score', color='#1f2937', fontsize=11)
ax.set_title('Customer Satisfaction Evolution', color='#1f2937', fontsize=14, fontweight='bold', pad=15)
ax.tick_params(colors='#374151', labelsize=9)
for spine in ax.spines.values():
    spine.set_color('#e5e7eb')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.set_xlim(1, 24)
ax.set_ylim(20, 70)
ax.legend(facecolor='#ffffff', edgecolor='#e5e7eb', labelcolor='#1f2937')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support