Ridgeline Plot
Network Latency by Region
Network response time distributions across global regions
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
np.random.seed(42)
regions = ['US-East', 'US-West', 'Europe', 'Asia', 'Australia']
colors = ['#276CF5', '#27D3F5', '#6CF527', '#F5B027', '#F5276C']
# Generate latency data in milliseconds
data = {
'US-East': np.concatenate([np.random.normal(25, 8, 250), np.random.normal(45, 15, 100)]),
'US-West': np.concatenate([np.random.normal(30, 10, 250), np.random.normal(55, 18, 100)]),
'Europe': np.concatenate([np.random.normal(80, 20, 250), np.random.normal(120, 30, 100)]),
'Asia': np.concatenate([np.random.normal(150, 35, 250), np.random.normal(200, 40, 100)]),
'Australia': np.concatenate([np.random.normal(180, 40, 250), np.random.normal(250, 50, 100)])
}
fig, ax = plt.subplots(figsize=(12, 8), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
overlap = 2.5
x_range = np.linspace(0, 350, 300)
for i, (region, latency) in enumerate(data.items()):
latency = np.clip(latency, 0, 350)
kde = stats.gaussian_kde(latency, bw_method=0.25)
y = kde(x_range) * 10
baseline = i * overlap
ax.fill_between(x_range, baseline, y + baseline,
alpha=0.7, color=colors[i], linewidth=0)
ax.plot(x_range, y + baseline, color=colors[i], linewidth=2)
ax.text(-10, baseline + 0.3, region, fontsize=11, color='white',
ha='right', va='bottom', fontweight='500')
ax.set_xlim(-50, 350)
ax.set_ylim(-0.5, len(regions) * overlap + 2)
ax.set_xlabel('Latency (ms)', fontsize=12, color='white', fontweight='500')
ax.set_title('Network Latency by Region', fontsize=16, color='white',
fontweight='bold', pad=20)
ax.tick_params(axis='x', colors='#888888', labelsize=10)
ax.tick_params(axis='y', left=False, labelleft=False)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['bottom'].set_color('#333333')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Ridgeline Plot examples
☕