ANOVA Violin Plot

Cloud Server Response Time ANOVA

Statistical comparison of API response latency across cloud providers.

Output
Cloud Server Response Time ANOVA
Python
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats

np.random.seed(888)

# Response time in milliseconds
aws = np.random.lognormal(3.5, 0.4, 200)
azure = np.random.lognormal(3.6, 0.45, 200)
gcp = np.random.lognormal(3.45, 0.38, 200)
oracle = np.random.lognormal(3.8, 0.5, 200)

# Clip for visualization
aws = np.clip(aws, 0, 200)
azure = np.clip(azure, 0, 200)
gcp = np.clip(gcp, 0, 200)
oracle = np.clip(oracle, 0, 200)

F_stat, p_value = stats.f_oneway(aws, azure, gcp, oracle)

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

colors = ['#F5B027', '#27D3F5', '#F5276C', '#C82909']

parts = ax.violinplot([aws, azure, gcp, oracle], 
                       positions=[1, 2, 3, 4], showmeans=True, showmedians=True, widths=0.7)

for i, pc in enumerate(parts['bodies']):
    pc.set_facecolor(colors[i])
    pc.set_alpha(0.7)
    pc.set_edgecolor('white')
    pc.set_linewidth(1.5)

parts['cmeans'].set_color('#6CF527')
parts['cmeans'].set_linewidth(2.5)
parts['cmedians'].set_color('white')
for partname in ['cbars', 'cmins', 'cmaxes']:
    parts[partname].set_color('#555555')

# Percentile annotations at bottom
labels = ['AWS', 'Azure', 'GCP', 'Oracle Cloud']
for i, (data, color) in enumerate(zip([aws, azure, gcp, oracle], colors)):
    p50 = np.percentile(data, 50)
    p99 = np.percentile(data, 99)
    ax.text(i+1, -25, f'P50:{p50:.0f} P99:{p99:.0f}', ha='center', fontsize=8, color=color)

# SLA threshold
ax.axhline(y=100, color='#ef4444', linestyle='--', alpha=0.7, linewidth=2)
ax.text(4.4, 100, 'SLA', fontsize=9, color='#ef4444', va='center')

# Uptime annotations at top
uptimes = ['99.99%', '99.95%', '99.99%', '99.9%']
for i, (uptime, color) in enumerate(zip(uptimes, colors)):
    ax.text(i+1, 215, uptime, ha='center', fontsize=9, color=color, fontweight='bold')

# Stats text - compact header
stats_text = f"ANOVA: F={F_stat:.2f}, p={p_value:.4f}"
bbox = dict(boxstyle="round,pad=0.3", facecolor='#0d1117', edgecolor='#27D3F5', lw=2)
ax.text(0.5, 1.02, stats_text, transform=ax.transAxes, fontsize=10, color='white',
        ha='center', va='bottom', fontfamily='monospace', bbox=bbox)

ax.set_xticks([1, 2, 3, 4])
ax.set_xticklabels(labels, fontsize=11, color='white')
ax.set_ylabel('Response Time (ms)', fontsize=12, color='white', fontweight='500')
ax.set_title('Cloud Provider API Latency Comparison\nProduction Workload Benchmarks', 
             fontsize=14, color='white', fontweight='bold', pad=25)

ax.tick_params(colors='#888888')
for spine in ax.spines.values():
    spine.set_color('#333333')
ax.yaxis.grid(True, color='#1a1a2e', linewidth=0.5)
ax.set_axisbelow(True)
ax.set_ylim(-40, 230)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support