Horizon Chart

Air Quality Index Horizon

Environmental horizon chart showing AQI levels with blue gradient for clean air periods.

Output
Air Quality Index Horizon
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'bands': ['#DBEAFE', '#93C5FD', '#3B82F6', '#1D4ED8'],
    'background': '#ffffff',
    'text': '#1f2937',
    'grid': '#e5e7eb',
}

np.random.seed(333)
hours = np.arange(0, 168)  # Week
# AQI pattern: higher during rush hours, lower at night
rush_hour = 30 * (np.exp(-((hours % 24 - 8)**2) / 10) + np.exp(-((hours % 24 - 18)**2) / 10))
aqi = 40 + rush_hour + np.random.normal(0, 10, len(hours))
aqi = np.clip(aqi, 0, 150)
aqi_norm = aqi / 150

fig, ax = plt.subplots(figsize=(14, 3), facecolor=COLORS['background'])
ax.set_facecolor(COLORS['background'])

band = 0.25

ax.fill_between(hours, 0, np.clip(aqi_norm, 0, band), color=COLORS['bands'][0])
ax.fill_between(hours, 0, np.clip(aqi_norm - band, 0, band), color=COLORS['bands'][1])
ax.fill_between(hours, 0, np.clip(aqi_norm - 2*band, 0, band), color=COLORS['bands'][2])
ax.fill_between(hours, 0, np.clip(aqi_norm - 3*band, 0, band), color=COLORS['bands'][3])

ax.set_xlim(0, 167)
ax.set_ylim(0, 0.3)

ax.set_title('Air Quality Index (Weekly)', color=COLORS['text'], fontsize=12, fontweight='bold', pad=10)
ax.set_xlabel('Day', color=COLORS['text'], fontsize=10)
ax.set_ylabel('AQI', color=COLORS['text'], fontsize=10)
ax.set_xticks([0, 24, 48, 72, 96, 120, 144])
ax.set_xticklabels(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'])

for spine in ax.spines.values():
    spine.set_color(COLORS['grid'])
ax.tick_params(colors=COLORS['text'], labelsize=9)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Time Series

Did this help you?

Support PyLucid to keep it free & growing

Support