ANOVA Boxplot

Call Center Handle Time ANOVA

Comparing average handle times across customer service teams.

Output
Call Center Handle Time ANOVA
Python
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats

np.random.seed(1414)

# Average handle time in minutes
team_alpha = np.random.normal(8.5, 2.0, 100)
team_beta = np.random.normal(7.2, 1.8, 100)
team_gamma = np.random.normal(9.8, 2.5, 100)
team_delta = np.random.normal(6.5, 1.5, 100)

team_alpha = np.clip(team_alpha, 3, 18)
team_beta = np.clip(team_beta, 2, 15)
team_gamma = np.clip(team_gamma, 4, 20)
team_delta = np.clip(team_delta, 2, 12)

F_stat, p_value = stats.f_oneway(team_alpha, team_beta, team_gamma, team_delta)

fig, ax = plt.subplots(figsize=(12, 7), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

colors = ['#F5276C', '#27D3F5', '#F5B027', '#6CF527']
data = [team_alpha, team_beta, team_gamma, team_delta]

bp = ax.boxplot(data, positions=[1, 2, 3, 4], widths=0.6, patch_artist=True,
                medianprops={'color': '#1f2937', 'linewidth': 2},
                whiskerprops={'color': '#9ca3af', 'linewidth': 1.5},
                capprops={'color': '#9ca3af', 'linewidth': 1.5},
                flierprops={'marker': 'o', 'markerfacecolor': '#d1d5db', 'markersize': 4})

for patch, color in zip(bp['boxes'], colors):
    patch.set_facecolor(color)
    patch.set_alpha(0.6)
    patch.set_edgecolor(color)
    patch.set_linewidth(2)

labels = ['Team Alpha', 'Team Beta', 'Team Gamma', 'Team Delta']

# Target AHT
ax.axhline(y=7.5, color='#22c55e', linestyle='--', alpha=0.7, linewidth=1.5)
ax.text(4.45, 7.5, 'Target', fontsize=8, color='#22c55e', va='center')

# FCR and CSAT
fcr = ['72%', '81%', '65%', '88%']
csat = ['4.1', '4.4', '3.8', '4.6']
for i, (d, f, c, color) in enumerate(zip(data, fcr, csat, colors)):
    ax.text(i+1, 0.5, f'FCR:{f} | CSAT:{c}', ha='center', fontsize=8, color=color)

# Stats header
stats_text = f"ANOVA: F={F_stat:.2f}, p={p_value:.4f} | Best: Team Delta (AHT={team_delta.mean():.1f}min)"
bbox = dict(boxstyle="round,pad=0.3", facecolor='#ecfdf5', edgecolor='#6CF527', lw=2)
ax.text(0.5, 1.02, stats_text, transform=ax.transAxes, fontsize=9, color='#1f2937',
        ha='center', va='bottom', fontfamily='monospace', bbox=bbox)

ax.set_xticks([1, 2, 3, 4])
ax.set_xticklabels(labels, fontsize=11, color='#1f2937')
ax.set_ylabel('Average Handle Time (minutes)', fontsize=12, color='#1f2937', fontweight='500')
ax.set_title('Customer Service Team Performance\nQ4 2024 Metrics', 
             fontsize=14, color='#1f2937', fontweight='bold', pad=25)

ax.tick_params(colors='#374151')
for spine in ax.spines.values():
    spine.set_color('#e5e7eb')
ax.yaxis.grid(True, color='#f3f4f6', linewidth=0.8)
ax.set_axisbelow(True)
ax.set_ylim(0, 22)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support