Ridgeline Plot

API Response Times by Endpoint

Response time distributions across different API endpoints

Output
API Response Times by Endpoint
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(42)
endpoints = ['/api/users', '/api/products', '/api/orders', '/api/search', '/api/auth', '/api/reports']
latencies = [45, 120, 85, 200, 35, 350]
variations = [15, 40, 30, 80, 10, 100]

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

colors = ['#27D3F5', '#6CF527', '#F5B027', '#F54927', '#F5276C', '#4927F5']

x = np.linspace(0, 600, 200)
overlap = 2.0

for i, (endpoint, lat, var, color) in enumerate(zip(endpoints, latencies, variations, colors)):
    data = np.random.gamma(lat/var, var, 1000)
    kde = stats.gaussian_kde(data)
    y = kde(x) * 80
    y_offset = i * overlap
    
    ax.fill_between(x, y_offset, y + y_offset, alpha=0.85, color=color, edgecolor='white', linewidth=0.8)
    ax.text(-20, y_offset + 0.3, endpoint, fontsize=9, color='white', va='center', ha='right', fontweight='500', family='monospace')

ax.set_xlim(-150, 600)
ax.set_ylim(-0.5, len(endpoints) * overlap + 2)
ax.set_xlabel('Response Time (ms)', color='white', fontsize=11, fontweight='500')
ax.set_title('API Response Times by Endpoint', color='white', fontsize=14, fontweight='bold', pad=20)
ax.tick_params(colors='#888888', labelsize=9)
ax.set_yticks([])
for spine in ax.spines.values():
    spine.set_visible(False)
ax.spines['bottom'].set_visible(True)
ax.spines['bottom'].set_color('#333333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support