Raincloud Plot
Coffee Shop Sales by Time of Day
Transaction amounts across daily periods
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt
np.random.seed(204)
BG_COLOR = '#ffffff'
TEXT_COLOR = '#1f2937'
COLORS = ['#F5B027', '#F5276C', '#27D3F5', '#5314E6']
times = ['Morning', 'Lunch', 'Afternoon', 'Evening']
data = pd.DataFrame({
'Sales': np.concatenate([
np.random.lognormal(1.8, 0.4, 150),
np.random.lognormal(2.0, 0.5, 120),
np.random.lognormal(1.6, 0.35, 100),
np.random.lognormal(1.9, 0.45, 80)
]),
'Time': ['Morning']*150 + ['Lunch']*120 + ['Afternoon']*100 + ['Evening']*80
})
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
pt.RainCloud(x='Time', y='Sales', data=data, palette=COLORS,
bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
dodge=True, pointplot=False, move=.2)
ax.set_xlabel('Transaction Amount ($)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Time Period', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Coffee Shop Sales by Time', 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
☕