Raincloud Plot
API Response Time by Region
Latency distribution across global data centers
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt
np.random.seed(107)
BG_COLOR = '#0a0a0f'
TEXT_COLOR = 'white'
COLORS = ['#4927F5', '#27F5B0', '#F54927']
regions = ['US-East', 'EU-West', 'Asia-Pacific']
data = pd.DataFrame({
'Latency': np.concatenate([
np.random.gamma(2, 15, 150),
np.random.gamma(2.5, 18, 140),
np.random.gamma(3, 20, 130)
]),
'Region': ['US-East']*150 + ['EU-West']*140 + ['Asia-Pacific']*130
})
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
pt.RainCloud(x='Region', y='Latency', data=data, palette=COLORS,
bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
dodge=True, pointplot=False, move=.2)
ax.set_xlabel('Response Time (ms)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Region', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('API Latency by Data Center', fontsize=14, color=TEXT_COLOR, fontweight='bold', pad=15)
ax.tick_params(colors='#888', labelsize=10)
for spine in ax.spines.values():
spine.set_color('#333')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Raincloud Plot examples
☕