Horizon Chart

EV Battery Discharge Horizon

Electric vehicle battery discharge horizon chart with lime green neon bands showing energy consumption.

Output
EV Battery Discharge Horizon
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'bands': ['#1a4d1a', '#2d802d', '#6CF527', '#A3E635'],
    'background': '#0a0a0f',
    'text': '#ffffff',
}

np.random.seed(1616)
minutes = np.arange(0, 480)  # 8 hour trip
# Battery: starts at 100%, decreases with driving patterns
base_drain = -0.15  # Base drain per minute
accel_events = np.random.choice([0, 1], size=len(minutes), p=[0.9, 0.1]) * np.random.uniform(0.3, 0.8, len(minutes))
regen = np.random.choice([0, 1], size=len(minutes), p=[0.95, 0.05]) * np.random.uniform(-0.2, 0, len(minutes))
charge_rate = base_drain - accel_events + regen + np.random.normal(0, 0.05, len(minutes))
charge_rate_norm = (charge_rate + 1) / 2  # Normalize to 0-1

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

band = 0.25

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

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

ax.set_title('EV Battery Discharge Rate', color=COLORS['text'], fontsize=12, fontweight='bold', pad=10)
ax.set_xlabel('Trip Duration', color=COLORS['text'], fontsize=10)
ax.set_ylabel('Discharge Rate', color=COLORS['text'], fontsize=10)
ax.set_xticks([0, 120, 240, 360, 480])
ax.set_xticklabels(['0h', '2h', '4h', '6h', '8h'])

for spine in ax.spines.values():
    spine.set_visible(False)
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