Horizon Chart
Bike Share Demand Horizon
Urban mobility horizon chart showing bike sharing demand with lime green gradient.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
COLORS = {
'bands': ['#ECFCCB', '#BEF264', '#84CC16', '#65A30D'],
'background': '#ffffff',
'text': '#1f2937',
'grid': '#e5e7eb',
}
np.random.seed(2525)
hours = np.arange(0, 168) # Week
# Bike demand: commute peaks, weather effects
commute_am = 40 * np.exp(-((hours % 24 - 8)**2) / 3)
commute_pm = 45 * np.exp(-((hours % 24 - 17.5)**2) / 3)
weekend_boost = np.where((hours % 168 > 120), 20 * np.exp(-((hours % 24 - 14)**2) / 10), 0)
# Rain effect (reduced demand)
rain = np.random.choice([0, 1], size=len(hours), p=[0.9, 0.1])
rain_effect = np.convolve(rain, np.ones(5)/5, mode='same') * -30
demand = commute_am + commute_pm + weekend_boost + rain_effect + np.random.normal(0, 5, len(hours))
demand = np.clip(demand, 0, 80)
demand_norm = demand / 80
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(demand_norm, 0, band), color=COLORS['bands'][0])
ax.fill_between(hours, 0, np.clip(demand_norm - band, 0, band), color=COLORS['bands'][1])
ax.fill_between(hours, 0, np.clip(demand_norm - 2*band, 0, band), color=COLORS['bands'][2])
ax.fill_between(hours, 0, np.clip(demand_norm - 3*band, 0, band), color=COLORS['bands'][3])
ax.set_xlim(0, 167)
ax.set_ylim(0, 0.3)
ax.set_title('Bike Share Demand (rentals/hour)', color=COLORS['text'], fontsize=12, fontweight='bold', pad=10)
ax.set_xlabel('Day', color=COLORS['text'], fontsize=10)
ax.set_ylabel('Rentals/hr', 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
More Horizon Chart examples
☕