Raincloud Plot
Delivery Time by Shipping Carrier
Package transit times across carriers
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt
np.random.seed(206)
BG_COLOR = '#ffffff'
TEXT_COLOR = '#1f2937'
COLORS = ['#F54927', '#F5B027', '#276CF5', '#6CF527']
carriers = ['FedEx', 'UPS', 'USPS', 'DHL']
data = pd.DataFrame({
'Days': np.concatenate([
np.random.gamma(2, 0.8, 100),
np.random.gamma(2.2, 0.9, 95),
np.random.gamma(3, 1.2, 110),
np.random.gamma(2.5, 1.0, 85)
]),
'Carrier': ['FedEx']*100 + ['UPS']*95 + ['USPS']*110 + ['DHL']*85
})
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
pt.RainCloud(x='Carrier', y='Days', data=data, palette=COLORS,
bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
dodge=True, pointplot=False, move=.2)
ax.set_xlabel('Delivery Time (days)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Carrier', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Delivery Time by Carrier', fontsize=14, color=TEXT_COLOR, fontweight='bold', pad=15)
ax.tick_params(colors='#374151', labelsize=10)
for spine in ax.spines.values():
spine.set_color('#e5e7eb')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Raincloud Plot examples
☕