Error Bar Chart

Food Delivery Time Comparison

Average delivery times for major food delivery services during regular and peak hours.

Output
Food Delivery Time Comparison
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

services = ['DoorDash', 'Uber Eats', 'Grubhub', 'Postmates', 'Instacart']
avg_time = np.array([32, 35, 38, 42, 28])
peak_time = np.array([48, 52, 58, 62, 42])
avg_err = np.array([5, 6, 7, 8, 4])
peak_err = np.array([10, 12, 14, 15, 8])

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

x = np.arange(len(services))
width = 0.35

ax.bar(x - width/2, avg_time, width, yerr=avg_err, label='Regular Hours',
       color='#27D3F5', edgecolor='white', linewidth=1.5, capsize=5,
       error_kw={'ecolor': '#374151', 'elinewidth': 2})
ax.bar(x + width/2, peak_time, width, yerr=peak_err, label='Peak Hours',
       color='#F5276C', edgecolor='white', linewidth=1.5, capsize=5,
       error_kw={'ecolor': '#374151', 'elinewidth': 2})

ax.axhline(y=30, color='#6CF527', linestyle='--', linewidth=2, 
           label='Target (30 min)', alpha=0.8)

ax.set_xlabel('Delivery Service', fontsize=12, color='#374151', fontweight='600')
ax.set_ylabel('Delivery Time (minutes)', fontsize=12, color='#374151', fontweight='600')
ax.set_title('Food Delivery Time Comparison', fontsize=15, 
             color='#1f2937', fontweight='bold', pad=20)

ax.set_xticks(x)
ax.set_xticklabels(services, fontsize=11)
ax.legend(facecolor='#ffffff', edgecolor='#e5e7eb', fontsize=10)
ax.tick_params(colors='#6b7280', labelsize=10)
ax.set_ylim(0, 85)
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