Stackplot

Network Bandwidth

Traffic by protocol type.

Output
Network Bandwidth
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'https': '#10B981',
    'streaming': '#6366F1',
    'gaming': '#EC4899',
    'voip': '#F59E0B',
    'other': '#94A3B8',
    'background': '#0F172A',
    'text': '#E2E8F0',
    'grid': '#334155'
}

np.random.seed(42)
time = np.arange(24)
https = 200 + 100*np.sin(time/4) + np.random.normal(0, 20, 24)
streaming = 150 + 80*np.sin((time-8)/4) + np.random.normal(0, 15, 24)
gaming = 50 + 100*np.where((time >= 18) | (time <= 2), 1, 0.3) + np.random.normal(0, 10, 24)
voip = 30 + 20*(time >= 9) * (time <= 17) + np.random.normal(0, 5, 24)
other = 40 + np.random.normal(0, 8, 24)

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

ax.stackplot(time, https, streaming, gaming, voip, other,
             colors=[COLORS['https'], COLORS['streaming'], COLORS['gaming'], COLORS['voip'], COLORS['other']],
             alpha=0.85, labels=['HTTPS', 'Streaming', 'Gaming', 'VoIP', 'Other'])

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.tick_params(axis='both', colors=COLORS['text'], labelsize=9, length=0, pad=8)
ax.set_xlim(0, 23)
ax.set_xticks([0, 6, 12, 18, 23])
ax.set_xticklabels(['12AM', '6AM', '12PM', '6PM', '11PM'])
ax.set_ylabel('Bandwidth (Mbps)', fontsize=10, color=COLORS['text'], labelpad=10)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=5, frameon=False, fontsize=9, labelcolor=COLORS['text'])

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support