Raincloud Plot
Marathon Finish Times by Experience Level
Race completion times across runner categories
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt
np.random.seed(111)
BG_COLOR = '#0a0a0f'
TEXT_COLOR = 'white'
COLORS = ['#F5276C', '#F5B027', '#6CF527']
levels = ['Beginner', 'Intermediate', 'Elite']
data = pd.DataFrame({
'Time': np.concatenate([
np.random.normal(280, 40, 150),
np.random.normal(220, 30, 120),
np.random.normal(160, 15, 60)
]),
'Level': ['Beginner']*150 + ['Intermediate']*120 + ['Elite']*60
})
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
pt.RainCloud(x='Level', y='Time', data=data, palette=COLORS,
bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
dodge=True, pointplot=False, move=.2)
ax.set_xlabel('Finish Time (minutes)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Experience Level', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Marathon Times by Experience', 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
☕