Polar Chart

Wind Direction Frequency Rose

Wind speed and direction frequency with stacked segments

Output
Wind Direction Frequency Rose
Python
import matplotlib.pyplot as plt
import numpy as np

directions = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']
speeds_low = [8, 12, 15, 10, 6, 14, 18, 11]
speeds_med = [5, 8, 10, 7, 4, 9, 12, 7]
speeds_high = [2, 4, 5, 3, 2, 4, 6, 3]

angles = np.linspace(0, 2 * np.pi, len(directions), endpoint=False)
width = 2 * np.pi / len(directions) * 0.7

fig, ax = plt.subplots(figsize=(10, 10), subplot_kw=dict(polar=True), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

bars1 = ax.bar(angles, speeds_low, width=width, bottom=0, alpha=0.8, color='#27D3F5', edgecolor='white', linewidth=1)
bars2 = ax.bar(angles, speeds_med, width=width, bottom=speeds_low, alpha=0.8, color='#F5B027', edgecolor='white', linewidth=1)
bars3 = ax.bar(angles, speeds_high, width=width, bottom=np.array(speeds_low)+np.array(speeds_med), alpha=0.8, color='#F5276C', edgecolor='white', linewidth=1)

ax.set_xticks(angles)
ax.set_xticklabels(directions, fontsize=12, color='#1f2937', fontweight='600')
ax.set_ylim(0, 40)
ax.spines['polar'].set_color('#e5e7eb')
ax.grid(color='#e5e7eb', linewidth=0.8)
ax.tick_params(axis='y', colors='#374151', labelsize=9)
ax.set_title('Wind Direction Frequency Rose', fontsize=16, color='#1f2937', fontweight='bold', pad=20, y=1.08)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Part-to-Whole

Did this help you?

Support PyLucid to keep it free & growing

Support