Raincloud Plot

House Price by Neighborhood

Real estate prices across city areas

Output
House Price by Neighborhood
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt

np.random.seed(208)
BG_COLOR = '#ffffff'
TEXT_COLOR = '#1f2937'
COLORS = ['#6CF527', '#F5B027', '#F5276C', '#4927F5']

hoods = ['Downtown', 'Suburbs', 'Waterfront', 'Historic']
data = pd.DataFrame({
    'Price': np.concatenate([
        np.random.lognormal(13.2, 0.4, 70),
        np.random.lognormal(12.8, 0.35, 100),
        np.random.lognormal(13.5, 0.5, 50),
        np.random.lognormal(13.0, 0.45, 60)
    ]),
    'Area': ['Downtown']*70 + ['Suburbs']*100 + ['Waterfront']*50 + ['Historic']*60
})
data['Price'] = data['Price'] / 1000  # Convert to thousands

fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)

pt.RainCloud(x='Area', y='Price', data=data, palette=COLORS,
             bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
             dodge=True, pointplot=False, move=.2)

ax.set_xlabel('Price ($K)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Neighborhood', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('House Prices by Neighborhood', 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

Did this help you?

Support PyLucid to keep it free & growing

Support