Error Bar Chart

Renewable Energy Production

Solar and wind energy output variation throughout the year showing seasonal patterns and uncertainty.

Output
Renewable Energy Production
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

# Renewable energy data
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
solar = np.array([120, 145, 210, 280, 350, 380, 395, 370, 290, 200, 140, 110])
wind = np.array([380, 350, 320, 280, 240, 200, 180, 190, 250, 310, 360, 390])
solar_var = np.array([25, 30, 35, 40, 45, 40, 35, 38, 35, 30, 25, 22])
wind_var = np.array([60, 55, 50, 45, 40, 35, 30, 32, 42, 50, 58, 62])

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

x = np.arange(len(months))

ax.errorbar(x, solar, yerr=solar_var, fmt='o-', color='#F5B027',
            ecolor='#F5B027', elinewidth=1.5, capsize=4, markersize=8,
            markeredgecolor='white', linewidth=2.5, label='Solar', alpha=0.9)
ax.fill_between(x, solar - solar_var, solar + solar_var, color='#F5B027', alpha=0.15)

ax.errorbar(x, wind, yerr=wind_var, fmt='s-', color='#27D3F5',
            ecolor='#27D3F5', elinewidth=1.5, capsize=4, markersize=8,
            markeredgecolor='white', linewidth=2.5, label='Wind', alpha=0.9)
ax.fill_between(x, wind - wind_var, wind + wind_var, color='#27D3F5', alpha=0.15)

# Combined output
combined = solar + wind
ax.plot(x, combined, '--', color='#6CF527', linewidth=2, 
        label='Combined', alpha=0.8)

ax.set_xlabel('Month', fontsize=11, color='white', fontweight='500')
ax.set_ylabel('Energy Output (GWh)', fontsize=11, color='white', fontweight='500')
ax.set_title('Renewable Energy Production Throughout Year', fontsize=14, 
             color='white', fontweight='bold', pad=15)

ax.set_xticks(x)
ax.set_xticklabels(months)
ax.legend(facecolor='#1a1a2e', edgecolor='#333', labelcolor='white', fontsize=10)
ax.tick_params(colors='#94a3b8', labelsize=9)
ax.set_ylim(0, 550)
ax.grid(True, alpha=0.2, color='#4a4a6a')
for spine in ax.spines.values():
    spine.set_color('#333333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support