Error Bar Chart

Sprint Performance Comparison

Elite sprinter times in 100m and 200m events showing performance variability across races.

Output
Sprint Performance Comparison
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

# Athletic data - sprint times
athletes = ['Thompson', 'Fraser-Pryce', 'Jackson', 'Richardson', 'Ta Lou']
times_100m = np.array([10.54, 10.62, 10.65, 10.71, 10.78])
times_200m = np.array([21.45, 21.79, 21.52, 21.85, 22.15])
err_100m = np.array([0.05, 0.06, 0.04, 0.07, 0.05])
err_200m = np.array([0.12, 0.14, 0.10, 0.15, 0.11])

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5), facecolor='#0a0a0f')

for ax in [ax1, ax2]:
    ax.set_facecolor('#0a0a0f')

# 100m
y_pos = np.arange(len(athletes))
ax1.barh(y_pos, times_100m, xerr=err_100m, height=0.6, color='#F5B027',
         edgecolor='white', capsize=4,
         error_kw={'ecolor': 'white', 'elinewidth': 1.5, 'capthick': 1.5})
ax1.set_yticks(y_pos)
ax1.set_yticklabels(athletes)
ax1.set_xlabel('Time (seconds)', fontsize=11, color='white', fontweight='500')
ax1.set_title('100m Sprint Times', fontsize=13, color='white', fontweight='bold', pad=10)
ax1.set_xlim(10.3, 11.0)
ax1.invert_xaxis()
ax1.tick_params(colors='#94a3b8', labelsize=9)
ax1.grid(True, axis='x', alpha=0.2, color='#4a4a6a')
for spine in ax1.spines.values():
    spine.set_color('#333333')

# 200m  
ax2.barh(y_pos, times_200m, xerr=err_200m, height=0.6, color='#27D3F5',
         edgecolor='white', capsize=4,
         error_kw={'ecolor': 'white', 'elinewidth': 1.5, 'capthick': 1.5})
ax2.set_yticks(y_pos)
ax2.set_yticklabels([])
ax2.set_xlabel('Time (seconds)', fontsize=11, color='white', fontweight='500')
ax2.set_title('200m Sprint Times', fontsize=13, color='white', fontweight='bold', pad=10)
ax2.set_xlim(21.0, 22.5)
ax2.tick_params(colors='#94a3b8', labelsize=9)
ax2.grid(True, axis='x', alpha=0.2, color='#4a4a6a')
for spine in ax2.spines.values():
    spine.set_color('#333333')

plt.suptitle('Elite Sprinter Performance Comparison', fontsize=14, 
             color='white', fontweight='bold', y=1.02)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support