Raincloud Plot
Restaurant Review Scores by Cuisine
Yelp ratings distribution by restaurant type
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt
np.random.seed(116)
BG_COLOR = '#0a0a0f'
TEXT_COLOR = 'white'
COLORS = ['#C82909', '#F5D327', '#27F5B0', '#F527B0']
cuisines = ['Italian', 'Japanese', 'Mexican', 'Indian']
data = pd.DataFrame({
'Rating': np.concatenate([
np.random.beta(8, 2, 100) * 5,
np.random.beta(9, 2, 95) * 5,
np.random.beta(7, 2.5, 110) * 5,
np.random.beta(8.5, 2, 90) * 5
]),
'Cuisine': ['Italian']*100 + ['Japanese']*95 + ['Mexican']*110 + ['Indian']*90
})
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
pt.RainCloud(x='Cuisine', y='Rating', data=data, palette=COLORS,
bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
dodge=True, pointplot=False, move=.2)
ax.set_xlabel('Rating (out of 5)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Cuisine Type', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Restaurant Ratings by Cuisine', 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
☕