Area Chart
Day Night Activity
Activity pattern with day/night shading.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# Data - Activity patterns
hours = np.arange(0, 24)
activity = [5, 3, 2, 2, 3, 8, 25, 55, 70, 75, 78, 80, 75, 72, 70, 65, 60, 55, 45, 35, 25, 18, 12, 8]
# Figure - LIGHT THEME
fig, ax = plt.subplots(figsize=(10, 6), facecolor='#ffffff')
ax.set_facecolor('#ffffff')
# Day/night shading
ax.axvspan(0, 6, alpha=0.1, color='#4927F5', label='Night')
ax.axvspan(6, 18, alpha=0.1, color='#F5B027', label='Day')
ax.axvspan(18, 24, alpha=0.1, color='#4927F5')
# Activity curve
ax.fill_between(hours, 0, activity, alpha=0.5, color='#F5276C')
ax.plot(hours, activity, color='#F5276C', linewidth=2.5)
# Peak marker
peak_hour = np.argmax(activity)
ax.scatter([peak_hour], [activity[peak_hour]], color='#F5276C', s=100, zorder=5, edgecolors='white', linewidth=2)
ax.annotate(f'Peak: {activity[peak_hour]}%', (peak_hour, activity[peak_hour]), xytext=(10, 10),
textcoords='offset points', color='#1f2937', fontsize=10, fontweight='bold')
# Styling
ax.set_xlabel('Hour of Day', color='#1f2937', fontsize=11)
ax.set_ylabel('Activity Level (%)', color='#1f2937', fontsize=11)
ax.set_title('Daily Activity Pattern', color='#1f2937', fontsize=14, fontweight='bold', pad=15)
ax.tick_params(colors='#374151', labelsize=9)
ax.set_xticks([0, 4, 8, 12, 16, 20, 24])
ax.set_xticklabels(['12AM', '4AM', '8AM', '12PM', '4PM', '8PM', '12AM'])
for spine in ax.spines.values():
spine.set_color('#e5e7eb')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.yaxis.grid(True, color='#f3f4f6', linewidth=0.5)
ax.set_xlim(0, 23)
ax.set_ylim(0, 100)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Basic Charts
More Area Chart examples
☕