KDE Plot

Internet Download Speed Distribution

KDE of broadband download speeds with ISP comparison.

Output
Internet Download Speed Distribution
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(104)

fiber = np.random.normal(450, 80, 400)
cable = np.random.normal(200, 50, 500)
dsl = np.random.normal(50, 20, 300)

fig, ax = plt.subplots(figsize=(12, 6), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

x = np.linspace(0, 600, 500)

isps = [
    (fiber, 'Fiber', '#276CF5'),
    (cable, 'Cable', '#27D3F5'),
    (dsl, 'DSL', '#F5B027'),
]

for data, label, color in isps:
    kde = stats.gaussian_kde(data)
    y = kde(x)
    mean_val = np.mean(data)
    ax.fill_between(x, y, alpha=0.3, color=color)
    ax.plot(x, y, color=color, linewidth=2.5, label=label + ' (' + str(int(mean_val)) + ' Mbps)')

ax.axvline(100, color='#6CF527', linestyle='--', linewidth=2, alpha=0.7, label='FCC Broadband')

ax.set_xlabel('Download Speed (Mbps)', fontsize=12, color='#1f2937', fontweight='500')
ax.set_ylabel('Density', fontsize=12, color='#1f2937', fontweight='500')
ax.set_title('Internet Download Speed by Connection Type', fontsize=16, color='#1f2937', fontweight='bold', pad=15)

ax.tick_params(colors='#374151', labelsize=10)
for spine in ax.spines.values():
    spine.set_color('#d1d5db')
ax.legend(loc='upper right', facecolor='#f9fafb', edgecolor='#d1d5db', labelcolor='#374151')
ax.grid(True, alpha=0.3, color='#e5e7eb')
ax.set_xlim(0, 600)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support