Horizon Chart
Sleep Quality Score Horizon
Personal health horizon chart tracking sleep quality variations with indigo/purple gradient.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
COLORS = {
'bands': ['#E0E7FF', '#A5B4FC', '#6366F1', '#4F46E5'],
'background': '#ffffff',
'text': '#1f2937',
'grid': '#e5e7eb',
}
np.random.seed(1313)
days = np.arange(0, 90) # 3 months
# Sleep quality: weekly pattern with weekends better
weekly = 10 * np.sin(days * 2 * np.pi / 7)
trend = 5 * np.sin(days * np.pi / 45) # Monthly variation
sleep = 70 + weekly + trend + np.random.normal(0, 8, len(days))
sleep = np.clip(sleep, 40, 100)
sleep_norm = sleep / 100
fig, ax = plt.subplots(figsize=(14, 3), facecolor=COLORS['background'])
ax.set_facecolor(COLORS['background'])
band = 0.25
ax.fill_between(days, 0, np.clip(sleep_norm, 0, band), color=COLORS['bands'][0])
ax.fill_between(days, 0, np.clip(sleep_norm - band, 0, band), color=COLORS['bands'][1])
ax.fill_between(days, 0, np.clip(sleep_norm - 2*band, 0, band), color=COLORS['bands'][2])
ax.fill_between(days, 0, np.clip(sleep_norm - 3*band, 0, band), color=COLORS['bands'][3])
ax.set_xlim(0, 89)
ax.set_ylim(0, 0.3)
ax.set_title('Sleep Quality Score (3 Months)', color=COLORS['text'], fontsize=12, fontweight='bold', pad=10)
ax.set_xlabel('Week', color=COLORS['text'], fontsize=10)
ax.set_ylabel('Quality Score', color=COLORS['text'], fontsize=10)
ax.set_xticks([0, 14, 28, 42, 56, 70, 84])
ax.set_xticklabels(['W1', 'W2', 'W4', 'W6', 'W8', 'W10', 'W12'])
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
☕