Stairs Plot

Download Progress

File download speed over time.

Output
Download Progress
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {'speed': '#10B981', 'background': '#FFFFFF', 'text': '#1E293B', 'text_muted': '#64748B', 'grid': '#F1F5F9'}

np.random.seed(42)
seconds = 20
speed = np.clip([0, 5, 15, 25, 30, 28, 32, 35, 33, 38, 40, 42, 38, 35, 40, 42, 45, 43, 40, 0], 0, 50)
edges = np.arange(len(speed) + 1)

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

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

# Peak annotation
peak_idx = np.argmax(speed)
ax.scatter([peak_idx + 0.5], [speed[peak_idx]], s=60, c=COLORS['speed'], edgecolors='white', linewidths=2, zorder=4)
ax.annotate(f'Peak: {speed[peak_idx]} MB/s', (peak_idx + 0.5, speed[peak_idx]), 
            xytext=(5, 8), textcoords='offset points', fontsize=9, color=COLORS['speed'], fontweight='bold')

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, 20)
ax.set_ylim(0, 55)
ax.set_xlabel('Time (s)', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Speed (MB/s)', 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