Horizon Chart
E-commerce Conversion Horizon
Business analytics horizon chart showing e-commerce conversion rates with green success gradient.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
COLORS = {
'bands': ['#DCFCE7', '#86EFAC', '#22C55E', '#16A34A'],
'background': '#ffffff',
'text': '#1f2937',
'grid': '#e5e7eb',
}
np.random.seed(1515)
hours = np.arange(0, 336) # 2 weeks
# Conversion: higher on weekends, peaks during promotions
daily = 2 + 1.5 * np.sin(hours * 2 * np.pi / 24 - np.pi/2) # Afternoon peak
weekend_boost = np.where((hours % 168 > 120) | (hours % 168 < 48), 1.0, 0)
promo = np.zeros(len(hours))
promo[72:96] = 2 # Flash sale
promo[240:264] = 2.5 # Weekend promo
conversion = daily + weekend_boost + promo + np.random.normal(0, 0.5, len(hours))
conversion = np.clip(conversion, 0, 8)
conversion_norm = conversion / 8
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(conversion_norm, 0, band), color=COLORS['bands'][0])
ax.fill_between(hours, 0, np.clip(conversion_norm - band, 0, band), color=COLORS['bands'][1])
ax.fill_between(hours, 0, np.clip(conversion_norm - 2*band, 0, band), color=COLORS['bands'][2])
ax.fill_between(hours, 0, np.clip(conversion_norm - 3*band, 0, band), color=COLORS['bands'][3])
ax.set_xlim(0, 335)
ax.set_ylim(0, 0.3)
ax.set_title('E-commerce Conversion Rate (%)', color=COLORS['text'], fontsize=12, fontweight='bold', pad=10)
ax.set_xlabel('Day', color=COLORS['text'], fontsize=10)
ax.set_ylabel('Conversion (%)', color=COLORS['text'], fontsize=10)
ax.set_xticks([0, 48, 96, 144, 192, 240, 288, 336])
ax.set_xticklabels(['Mon', 'Wed', 'Fri', 'Sun', 'Tue', 'Thu', 'Sat', ''])
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
☕