Boxplot

Latency Percentiles

Service latency analysis.

Output
Latency Percentiles
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {'box': '#374151', 'sla': '#EF4444', 'median': '#FFFFFF', 'background': '#FFFFFF', 'text': '#1E293B', 'text_muted': '#64748B', 'grid': '#F1F5F9'}

np.random.seed(42)
data = [np.random.exponential(s, 200) for s in [15, 25, 40, 20, 35]]

fig, ax = plt.subplots(figsize=(12, 5), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])

bp = ax.boxplot(data, vert=False, widths=0.6, patch_artist=True, showfliers=False,
                medianprops=dict(color=COLORS['median'], linewidth=2),
                boxprops=dict(facecolor=COLORS['box'], edgecolor='white'),
                whiskerprops=dict(color=COLORS['box']), capprops=dict(color=COLORS['box']))

ax.axvline(100, color=COLORS['sla'], linewidth=2, linestyle='--', label='SLA: 100ms')
ax.set_yticklabels(['Auth Service', 'User Service', 'Order Service', 'Payment Service', 'Notification'])
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color(COLORS['grid'])
ax.spines['bottom'].set_color(COLORS['grid'])
ax.xaxis.grid(True, color=COLORS['grid'], linewidth=1, zorder=0)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_xlabel('Latency (ms)', fontsize=10, color=COLORS['text'], labelpad=10)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12), frameon=False, fontsize=9, labelcolor=COLORS['text_muted'])

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support