Error Bar Chart

Wearable Device Accuracy Study

Accuracy comparison of popular fitness wearables across different health metrics.

Output
Wearable Device Accuracy Study
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

metrics = ['Steps', 'Heart Rate', 'Calories', 'Sleep', 'Distance']
apple = np.array([97, 98, 85, 88, 96])
fitbit = np.array([95, 96, 82, 90, 94])
garmin = np.array([96, 97, 84, 86, 98])
err = np.array([2, 1.5, 5, 4, 2])

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

x = np.arange(len(metrics))
width = 0.25

ax.bar(x - width, apple, width, yerr=err, label='Apple Watch',
       color='#374151', edgecolor='white', linewidth=1.5, capsize=4,
       error_kw={'ecolor': '#6b7280', 'elinewidth': 1.5})
ax.bar(x, fitbit, width, yerr=err, label='Fitbit',
       color='#27D3F5', edgecolor='white', linewidth=1.5, capsize=4,
       error_kw={'ecolor': '#6b7280', 'elinewidth': 1.5})
ax.bar(x + width, garmin, width, yerr=err, label='Garmin',
       color='#F5B027', edgecolor='white', linewidth=1.5, capsize=4,
       error_kw={'ecolor': '#6b7280', 'elinewidth': 1.5})

ax.axhline(y=95, color='#6CF527', linestyle='--', linewidth=2, alpha=0.7)

ax.set_xlabel('Metric', fontsize=12, color='#374151', fontweight='600')
ax.set_ylabel('Accuracy (%)', fontsize=12, color='#374151', fontweight='600')
ax.set_title('Wearable Device Accuracy Study', fontsize=15, 
             color='#1f2937', fontweight='bold', pad=20)

ax.set_xticks(x)
ax.set_xticklabels(metrics, fontsize=11)
ax.legend(facecolor='#ffffff', edgecolor='#e5e7eb', fontsize=10, loc='lower right')
ax.tick_params(colors='#6b7280', labelsize=10)
ax.set_ylim(70, 105)
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