Polar Chart

Energy Consumption by Hour

Daily power usage pattern with stacked segments - light theme

Output
Energy Consumption by Hour
Python
import matplotlib.pyplot as plt
import numpy as np

hours = [f'{i}' for i in range(24)]
hvac = [15, 12, 10, 10, 12, 18, 25, 30, 28, 25, 22, 20, 22, 25, 28, 30, 32, 30, 28, 25, 22, 20, 18, 16]
lighting = [8, 5, 3, 2, 2, 5, 12, 15, 12, 10, 10, 10, 10, 10, 12, 15, 18, 20, 18, 15, 12, 10, 10, 9]
appliances = [5, 3, 2, 2, 2, 5, 15, 18, 12, 8, 8, 12, 15, 12, 10, 12, 18, 22, 20, 15, 10, 8, 6, 5]

angles = np.linspace(0, 2 * np.pi, 24, endpoint=False)
width = 2 * np.pi / 24 * 0.85

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

ax.bar(angles, hvac, width=width, bottom=0, alpha=0.8, color='#F54927', label='HVAC')
ax.bar(angles, lighting, width=width, bottom=hvac, alpha=0.8, color='#F5B027', label='Lighting')
ax.bar(angles, appliances, width=width, bottom=np.array(hvac)+np.array(lighting), alpha=0.8, color='#27D3F5', label='Appliances')

ax.set_xticks(angles[::3])
ax.set_xticklabels([f'{i}:00' for i in range(0, 24, 3)], fontsize=10, color='#1f2937', fontweight='500')
ax.set_ylim(0, 80)
ax.spines['polar'].set_color('#e5e7eb')
ax.grid(color='#e5e7eb', linewidth=0.8)
ax.legend(loc='upper right', bbox_to_anchor=(1.25, 1.1), fontsize=10)
ax.set_title('Energy Consumption by Hour', 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