Error Bar Chart

EV Charger Speed by Type

Electric vehicle charging speed comparison across different charger types.

Output
EV Charger Speed by Type
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

charger_types = ['Level 1\n(120V)', 'Level 2\n(240V)', 'DC Fast\n50kW', 'Tesla\nSupercharger', 'Ultra-Fast\n350kW']
miles_per_hour = np.array([4, 25, 180, 250, 500])
variability = np.array([0.5, 3, 25, 35, 75])

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

x = np.arange(len(charger_types))
colors = ['#9ca3af', '#27D3F5', '#6CF527', '#F5276C', '#5314E6']

bars = ax.bar(x, miles_per_hour, yerr=variability, capsize=6,
              color=colors, edgecolor='white', linewidth=2,
              error_kw={'ecolor': '#374151', 'elinewidth': 2, 'capthick': 2},
              alpha=0.9, width=0.65)

for bar, mph, var in zip(bars, miles_per_hour, variability):
    ax.text(bar.get_x() + bar.get_width()/2, bar.get_height() + var + 15,
            f'{mph}', ha='center', color='#374151', fontsize=11, fontweight='700')

ax.set_xlabel('Charger Type', fontsize=12, color='#374151', fontweight='600')
ax.set_ylabel('Miles of Range per Hour', fontsize=12, color='#374151', fontweight='600')
ax.set_title('Electric Vehicle Charging Speed by Type', fontsize=15, 
             color='#1f2937', fontweight='bold', pad=20)

ax.set_xticks(x)
ax.set_xticklabels(charger_types, fontsize=10)
ax.tick_params(colors='#6b7280', labelsize=10)
ax.set_ylim(0, 620)
ax.grid(True, axis='y', alpha=0.4, color='#e5e7eb')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#d1d5db')
ax.spines['bottom'].set_color('#d1d5db')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support