Horizon Chart

Database Query Load Horizon

Database performance horizon chart showing query load with orange/amber neon gradient.

Output
Database Query Load Horizon
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'bands': ['#4d2600', '#994d00', '#F59E0B', '#FBBF24'],
    'background': '#0a0a0f',
    'text': '#ffffff',
}

np.random.seed(1010)
seconds = np.arange(0, 3600)  # 1 hour
# DB load with periodic spikes (cron jobs)
base = 100 + 50 * np.sin(seconds * np.pi / 300)
cron_spikes = np.zeros(len(seconds))
cron_spikes[::900] = 200  # Every 15 minutes
cron_spikes = np.convolve(cron_spikes, np.exp(-np.arange(100)/20), mode='same')
load = base + cron_spikes + np.random.exponential(20, len(seconds))
load = np.clip(load, 0, 400)
load_norm = load / 400

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

band = 0.25

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

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

ax.set_title('Database Query Load (queries/sec)', color=COLORS['text'], fontsize=12, fontweight='bold', pad=10)
ax.set_xlabel('Time', color=COLORS['text'], fontsize=10)
ax.set_ylabel('Queries/sec', color=COLORS['text'], fontsize=10)
ax.set_xticks([0, 900, 1800, 2700, 3600])
ax.set_xticklabels(['00:00', '00:15', '00:30', '00:45', '01:00'])

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