Raincloud Plot
Energy Consumption by Building Type
Electricity usage across property types
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt
np.random.seed(219)
BG_COLOR = '#ffffff'
TEXT_COLOR = '#1f2937'
COLORS = ['#F5B027', '#27D3F5', '#6CF527', '#F5276C']
buildings = ['Office', 'Retail', 'Warehouse', 'Hospital']
data = pd.DataFrame({
'kWh': np.concatenate([
np.random.lognormal(4.5, 0.5, 80),
np.random.lognormal(4.2, 0.4, 90),
np.random.lognormal(3.8, 0.6, 70),
np.random.lognormal(5.0, 0.45, 60)
]),
'Building': ['Office']*80 + ['Retail']*90 + ['Warehouse']*70 + ['Hospital']*60
})
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
pt.RainCloud(x='Building', y='kWh', data=data, palette=COLORS,
bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
dodge=True, pointplot=False, move=.2)
ax.set_xlabel('Energy (kWh/sqft/year)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Building Type', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Energy Consumption by Building Type', 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
☕