2D Histogram
Wind Speed vs Power Output
2D histogram of wind turbine power generation versus wind speed.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
np.random.seed(42)
# Wind energy data
wind_speed = np.clip(np.random.weibull(2, 5000) * 10, 0, 30) # m/s
# Power curve: cubic up to rated, then flat
power = np.minimum(wind_speed**3 * 0.5, 1000) + np.random.normal(0, 50, 5000)
power = np.clip(power, 0, 1200)
fig, ax = plt.subplots(figsize=(10, 8), facecolor='#020B14')
ax.set_facecolor('#020B14')
# Custom colormap: lime to cyan
colors = ['#020B14', '#0d2d1a', '#6CF527', '#27D3F5']
cmap = LinearSegmentedColormap.from_list('wind', colors, N=256)
h = ax.hist2d(wind_speed, power, bins=45, cmap=cmap, cmin=1)
cbar = plt.colorbar(h[3], ax=ax, pad=0.02)
cbar.set_label('Readings', color='white', fontsize=11)
cbar.ax.yaxis.set_tick_params(color='white')
plt.setp(plt.getp(cbar.ax.axes, 'yticklabels'), color='white')
ax.set_xlabel('Wind Speed (m/s)', fontsize=11, color='white', fontweight='500')
ax.set_ylabel('Power Output (kW)', fontsize=11, color='white', fontweight='500')
ax.set_title('Wind Speed vs Power Output', fontsize=14, color='white', fontweight='bold', pad=15)
ax.tick_params(colors='white', labelsize=9)
for spine in ax.spines.values():
spine.set_color('#333333')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More 2D Histogram examples
☕