Horizon Chart

Horizon Chart

Compact layered visualization of positive/negative.

Output
Horizon Chart
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'positive': ['#DBEAFE', '#93C5FD', '#3B82F6'],
    'negative': ['#FEE2E2', '#FCA5A5', '#EF4444'],
    'background': '#FFFFFF',
    'text': '#1E293B',
    'grid': '#E5E7EB',
}

np.random.seed(42)
x = np.linspace(0, 10, 100)
y = np.sin(x * 2) + 0.5 * np.cos(x * 5) + np.random.normal(0, 0.2, len(x))

fig, ax = plt.subplots(figsize=(12, 3), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])

# Layered positive bands
ax.fill_between(x, 0, np.clip(y, 0, 0.5), color=COLORS['positive'][0])
ax.fill_between(x, 0, np.clip(y - 0.5, 0, 0.5), color=COLORS['positive'][1])
ax.fill_between(x, 0, np.clip(y - 1.0, 0, 0.5), color=COLORS['positive'][2])

# Layered negative bands
ax.fill_between(x, 0, np.clip(y, -0.5, 0), color=COLORS['negative'][0])
ax.fill_between(x, 0, np.clip(y + 0.5, -0.5, 0), color=COLORS['negative'][1])
ax.fill_between(x, 0, np.clip(y + 1.0, -0.5, 0), color=COLORS['negative'][2])

ax.axhline(0, color=COLORS['text'], linewidth=0.5)
ax.set_xlim(0, 10)
ax.set_ylim(-0.6, 0.6)

ax.set_title('Signal Amplitude Over Time', color=COLORS['text'], fontsize=12, fontweight='bold', pad=10)
ax.set_xlabel('Time (seconds)', color=COLORS['text'], fontsize=10)
ax.set_ylabel('Amplitude', color=COLORS['text'], fontsize=10)

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