Raincloud Plot
Wine Quality Score by Region
Tasting scores across wine regions
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt
np.random.seed(212)
BG_COLOR = '#ffffff'
TEXT_COLOR = '#1f2937'
COLORS = ['#9C2007', '#F5B027', '#5314E6', '#27F5B0']
regions = ['Bordeaux', 'Napa Valley', 'Tuscany', 'Rioja']
data = pd.DataFrame({
'Score': np.concatenate([
np.random.beta(8, 2, 80) * 100,
np.random.beta(7.5, 2.5, 90) * 100,
np.random.beta(8.2, 2, 75) * 100,
np.random.beta(7, 2.8, 85) * 100
]),
'Region': ['Bordeaux']*80 + ['Napa Valley']*90 + ['Tuscany']*75 + ['Rioja']*85
})
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
pt.RainCloud(x='Region', y='Score', data=data, palette=COLORS,
bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
dodge=True, pointplot=False, move=.2)
ax.set_xlabel('Quality Score', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Wine Region', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Wine Quality by Region', 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
☕