Stairs Plot

Server Requests

API requests per minute.

Output
Server Requests
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {'requests': '#6366F1', 'background': '#FFFFFF', 'text': '#1E293B', 'text_muted': '#64748B', 'grid': '#F1F5F9'}

np.random.seed(42)
minutes = 30
requests = np.clip(200 + 100*np.sin(np.arange(minutes)/5) + np.random.normal(0, 30, minutes), 50, 400).astype(int)
edges = np.arange(minutes + 1)

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

ax.stairs(requests, edges, fill=True, alpha=0.2, facecolor=COLORS['requests'])
ax.stairs(requests, edges, linewidth=2, color=COLORS['requests'])

avg = np.mean(requests)
ax.axhline(avg, color=COLORS['requests'], linewidth=1.5, linestyle='--', alpha=0.7)
ax.text(30.5, avg, f'Avg: {avg:.0f}', fontsize=9, color=COLORS['requests'], va='center')

ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color(COLORS['grid'])
ax.spines['bottom'].set_color(COLORS['grid'])
ax.yaxis.grid(True, color=COLORS['grid'], linewidth=1, zorder=0)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_xlim(0, 30)
ax.set_xlabel('Minute', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Requests/min', fontsize=10, color=COLORS['text'], labelpad=10)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support