Error Bar Chart

Home Energy Solutions Impact

Electric bill savings/costs from various home energy solutions.

Output
Home Energy Solutions Impact
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

solutions = ['Solar\nPanels', 'Smart\nThermostat', 'LED\nLighting', 'Insulation', 'Smart\nPlugs', 'EV\nCharging']
savings_pct = np.array([65, 15, 8, 20, 5, -25])
variability = np.array([12, 4, 2, 5, 2, 8])

fig, ax = plt.subplots(figsize=(10, 6), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

x = np.arange(len(solutions))
colors = ['#6CF527' if s > 0 else '#F5276C' for s in savings_pct]

bars = ax.bar(x, savings_pct, yerr=variability, capsize=6,
              color=colors, edgecolor='white', linewidth=2,
              error_kw={'ecolor': '#374151', 'elinewidth': 2, 'capthick': 2},
              alpha=0.9, width=0.65)

ax.axhline(y=0, color='#374151', linestyle='-', linewidth=1)

ax.set_xlabel('Energy Solution', fontsize=12, color='#374151', fontweight='600')
ax.set_ylabel('Bill Change (%)', fontsize=12, color='#374151', fontweight='600')
ax.set_title('Home Energy Solutions Impact on Electric Bill', fontsize=15, 
             color='#1f2937', fontweight='bold', pad=20)

ax.set_xticks(x)
ax.set_xticklabels(solutions, fontsize=10)
ax.tick_params(colors='#6b7280', labelsize=10)
ax.set_ylim(-45, 85)
ax.grid(True, axis='y', alpha=0.4, color='#e5e7eb')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#d1d5db')
ax.spines['bottom'].set_color('#d1d5db')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support