Stream Graph
Renewable Energy Mix Stream
Stream graph showing the evolution of renewable energy sources in the global energy mix.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
COLORS = {
'layers': ['#FBBF24', '#06B6D4', '#3B82F6', '#10B981', '#8B5CF6'],
'background': '#ffffff',
'text': '#1f2937',
'grid': '#e5e7eb',
}
np.random.seed(505)
years = np.arange(2000, 2025)
n = len(years)
# Energy sources
solar = 1 + 0.5 * (years - 2000)**1.5 / 10 + np.random.normal(0, 1, n)
wind = 5 + 0.8 * (years - 2000)**1.3 / 5 + np.random.normal(0, 1, n)
hydro = 50 + 0.3 * (years - 2000) + np.random.normal(0, 2, n)
geothermal = 3 + 0.1 * (years - 2000) + np.random.normal(0, 0.5, n)
biomass = 8 + 0.2 * (years - 2000) + np.random.normal(0, 1, n)
data = [np.clip(d, 1, None) for d in [solar, wind, hydro, geothermal, biomass]]
fig, ax = plt.subplots(figsize=(14, 6), facecolor=COLORS['background'])
ax.set_facecolor(COLORS['background'])
ax.stackplot(years, *data, colors=COLORS['layers'], alpha=0.85, baseline='sym',
labels=['Solar', 'Wind', 'Hydro', 'Geothermal', 'Biomass'])
ax.axhline(0, color=COLORS['grid'], linewidth=0.5)
ax.set_xlim(2000, 2024)
ax.set_title('Renewable Energy Mix Evolution (2000-2024)', color=COLORS['text'], fontsize=14, fontweight='bold', pad=15)
ax.set_xlabel('Year', color=COLORS['text'], fontsize=11)
ax.set_ylabel('Capacity (GW)', color=COLORS['text'], fontsize=11)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12), frameon=False, fontsize=9, ncol=5)
for spine in ax.spines.values():
spine.set_color(COLORS['grid'])
ax.tick_params(colors=COLORS['text'], labelsize=9)
plt.tight_layout()
plt.subplots_adjust(bottom=0.18)
plt.show()
Library
Matplotlib
Category
Time Series
More Stream Graph examples
☕