Error Bar Chart

Server Latency by Geographic Region

Network response times from different geographic regions showing latency variation throughout the day.

Output
Server Latency by Geographic Region
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

# Network latency data
servers = ['US-East', 'US-West', 'EU-West', 'Asia-Pacific', 'South America']
hours = np.arange(0, 24, 3)

# Latency data with different patterns per region
latency = {
    'US-East': [25, 22, 28, 35, 42, 38, 30, 26],
    'US-West': [45, 42, 48, 55, 62, 58, 50, 46],
    'EU-West': [85, 82, 78, 75, 82, 88, 90, 86],
    'Asia-Pacific': [180, 175, 170, 165, 168, 175, 182, 178],
    'South America': [120, 115, 118, 125, 135, 130, 122, 118]
}
errors = {k: np.array(v) * 0.1 + np.random.rand(8) * 5 for k, v in latency.items()}

fig, ax = plt.subplots(figsize=(10, 6), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

colors = ['#27D3F5', '#6CF527', '#F5B027', '#F5276C', '#4927F5']
markers = ['o', 's', '^', 'D', 'v']

for (server, lat), color, marker in zip(latency.items(), colors, markers):
    ax.errorbar(hours, lat, yerr=errors[server], fmt=f'{marker}-', color=color,
                ecolor=color, elinewidth=1.5, capsize=4, capthick=1.5,
                markersize=8, markeredgecolor='white', markeredgewidth=1,
                label=server, linewidth=2, alpha=0.9)

ax.set_xlabel('Hour (UTC)', fontsize=11, color='white', fontweight='500')
ax.set_ylabel('Latency (ms)', fontsize=11, color='white', fontweight='500')
ax.set_title('Server Latency by Geographic Region', fontsize=14, 
             color='white', fontweight='bold', pad=15)

ax.legend(facecolor='#1a1a2e', edgecolor='#333', labelcolor='white', 
          fontsize=9, loc='upper right')
ax.set_xticks(hours)
ax.set_xticklabels([f'{h:02d}:00' for h in hours])
ax.tick_params(colors='#94a3b8', labelsize=9)
ax.grid(True, alpha=0.2, color='#4a4a6a')
for spine in ax.spines.values():
    spine.set_color('#333333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support