Stairs Plot

Queue Length

Task queue size over time.

Output
Queue Length
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {'queue': '#F59E0B', 'background': '#FFFFFF', 'text': '#1E293B', 'text_muted': '#64748B', 'grid': '#F1F5F9'}

time_points = np.arange(15)
queue = [5, 8, 12, 15, 18, 14, 10, 8, 12, 16, 20, 18, 14, 10, 6]
edges = np.arange(16)

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

ax.stairs(queue, edges, fill=True, alpha=0.25, facecolor=COLORS['queue'])
ax.stairs(queue, edges, linewidth=2.5, color=COLORS['queue'])

# Threshold
ax.axhline(15, color='#EF4444', linewidth=1.5, linestyle='--', alpha=0.7)
ax.text(15.2, 15, 'Threshold', fontsize=9, color='#EF4444', 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, 15)
ax.set_ylim(0, 25)
ax.set_xlabel('Time', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Queue Size', 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