Raincloud Plot
Electric Vehicle Range by Brand
EV range distribution across manufacturers
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt
np.random.seed(106)
BG_COLOR = '#0a0a0f'
TEXT_COLOR = 'white'
COLORS = ['#6CF527', '#F5B027', '#27D3F5', '#F5276C']
brands = ['Tesla', 'Rivian', 'Ford', 'Hyundai']
data = pd.DataFrame({
'Range': np.concatenate([
np.random.normal(320, 45, 80),
np.random.normal(290, 35, 60),
np.random.normal(250, 40, 70),
np.random.normal(270, 30, 65)
]),
'Brand': ['Tesla']*80 + ['Rivian']*60 + ['Ford']*70 + ['Hyundai']*65
})
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
pt.RainCloud(x='Brand', y='Range', data=data, palette=COLORS,
bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
dodge=True, pointplot=False, move=.2)
ax.set_xlabel('Range (miles)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Brand', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('EV Range by Manufacturer', 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
☕