Mirror Chart

Summer vs Winter Energy Usage

Mirror density comparing seasonal energy consumption with cost annotations

Output
Summer vs Winter Energy Usage
Python
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import gaussian_kde

np.random.seed(654)
BG_COLOR = '#0d1117'

# Energy (kWh/day)
summer = np.random.normal(42, 14, 800)
winter = np.random.normal(68, 18, 800)

fig, ax = plt.subplots(figsize=(12, 7), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)

x = np.linspace(0, 130, 500)

# Summer (top) - warm orange
kde_s = gaussian_kde(summer)
y_s = kde_s(x)
ax.fill_between(x, y_s, alpha=0.2, color='#F5B027')
ax.plot(x, y_s, color='#F5B027', linewidth=5, alpha=0.3)
ax.plot(x, y_s, color='#F5B027', linewidth=2.5, label=f'Summer (μ={np.mean(summer):.0f} kWh)')

# Winter (bottom) - cool cyan
kde_w = gaussian_kde(winter)
y_w = kde_w(x) * -1
ax.fill_between(x, y_w, alpha=0.2, color='#27D3F5')
ax.plot(x, y_w, color='#27D3F5', linewidth=5, alpha=0.3)
ax.plot(x, y_w, color='#27D3F5', linewidth=2.5, label=f'Winter (μ={np.mean(winter):.0f} kWh)')

ax.axhline(0, color='#444444', linewidth=1.5)

# Cost calculation ($0.12/kWh)
rate = 0.12
summer_cost = np.mean(summer) * rate * 30
winter_cost = np.mean(winter) * rate * 30
diff = winter_cost - summer_cost

# Cost annotations
ax.text(np.mean(summer), max(y_s)*1.1, f'~${summer_cost:.0f}/mo', 
        ha='center', fontsize=12, color='#F5B027', fontweight='bold')
ax.text(np.mean(winter), min(y_w)*1.1, f'~${winter_cost:.0f}/mo', 
        ha='center', fontsize=12, color='#27D3F5', fontweight='bold')

# Difference annotation
ax.annotate(f'+${diff:.0f}/mo', xy=(90, 0), fontsize=16, color='#F5276C',
            fontweight='bold', ha='center',
            bbox=dict(boxstyle='round,pad=0.3', facecolor=BG_COLOR, edgecolor='#F5276C', lw=2))

# Stats
pct_increase = ((np.mean(winter) - np.mean(summer)) / np.mean(summer)) * 100
stats = f"Winter Usage +{pct_increase:.0f}% | Rate: ${rate}/kWh"
ax.text(0.5, 0.98, stats, transform=ax.transAxes, ha='center', va='top',
        fontsize=10, color='#888888', fontfamily='monospace',
        bbox=dict(boxstyle='round,pad=0.4', facecolor=BG_COLOR, edgecolor='#333333'))

ax.set_xlabel('Daily Energy Usage (kWh)', fontsize=12, color='white', fontweight='500')
ax.set_title('Household Energy: Seasonal Comparison', fontsize=16, color='white', fontweight='bold', pad=25)

ax.tick_params(colors='#888888', labelsize=10)
ax.set_yticks([])
for spine in ['top', 'right']:
    ax.spines[spine].set_visible(False)
for spine in ['bottom', 'left']:
    ax.spines[spine].set_color('#333333')
ax.legend(loc='upper right', facecolor=BG_COLOR, edgecolor='#333333', labelcolor='white', fontsize=10)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support