Raincloud Plot
Heart Rate Variability by Fitness Level
HRV metrics across athlete categories
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt
np.random.seed(120)
BG_COLOR = '#0a0a0f'
TEXT_COLOR = 'white'
COLORS = ['#F5276C', '#27D3F5', '#6CF527']
levels = ['Sedentary', 'Active', 'Athlete']
data = pd.DataFrame({
'HRV': np.concatenate([
np.random.normal(35, 12, 100),
np.random.normal(55, 15, 90),
np.random.normal(80, 18, 60)
]),
'Level': ['Sedentary']*100 + ['Active']*90 + ['Athlete']*60
})
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
pt.RainCloud(x='Level', y='HRV', data=data, palette=COLORS,
bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
dodge=True, pointplot=False, move=.2)
ax.axvline(50, color='#22c55e', linestyle='--', alpha=0.6, linewidth=1.5)
ax.text(52, 2.5, 'Healthy', color='#22c55e', fontsize=9)
ax.set_xlabel('HRV (ms)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Fitness Level', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Heart Rate Variability by Fitness', 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
☕