Error Bar Chart
Student Performance by Subject
Academic performance comparison across subjects and classes with score variability.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
# Test score data
subjects = ['Math', 'Science', 'English', 'History', 'Art']
class_a = np.array([82, 78, 85, 75, 88])
class_b = np.array([79, 84, 81, 82, 85])
class_c = np.array([75, 80, 78, 79, 82])
err_a = np.array([5, 6, 4, 7, 5])
err_b = np.array([6, 5, 5, 5, 6])
err_c = np.array([7, 6, 6, 6, 5])
fig, ax = plt.subplots(figsize=(10, 6), facecolor='#ffffff')
ax.set_facecolor('#ffffff')
x = np.arange(len(subjects))
ax.errorbar(x - 0.2, class_a, yerr=err_a, fmt='o', color='#F5276C',
ecolor='#F5276C', elinewidth=2, capsize=5, markersize=12,
markeredgecolor='#1f2937', markeredgewidth=1, label='Class A', alpha=0.9)
ax.errorbar(x, class_b, yerr=err_b, fmt='s', color='#27D3F5',
ecolor='#27D3F5', elinewidth=2, capsize=5, markersize=11,
markeredgecolor='#1f2937', markeredgewidth=1, label='Class B', alpha=0.9)
ax.errorbar(x + 0.2, class_c, yerr=err_c, fmt='^', color='#6CF527',
ecolor='#6CF527', elinewidth=2, capsize=5, markersize=11,
markeredgecolor='#1f2937', markeredgewidth=1, label='Class C', alpha=0.9)
ax.axhline(y=80, color='#F5B027', linestyle='--', linewidth=1.5,
label='Pass Threshold', alpha=0.7)
ax.set_xlabel('Subject', fontsize=11, color='#374151', fontweight='500')
ax.set_ylabel('Average Score', fontsize=11, color='#374151', fontweight='500')
ax.set_title('Student Performance by Class and Subject', fontsize=14,
color='#1f2937', fontweight='bold', pad=15)
ax.set_xticks(x)
ax.set_xticklabels(subjects)
ax.legend(facecolor='#f8fafc', edgecolor='#d1d5db', fontsize=9, loc='lower right')
ax.tick_params(colors='#6b7280', labelsize=9)
ax.set_ylim(60, 100)
ax.grid(True, axis='y', alpha=0.3, color='#d1d5db')
for spine in ax.spines.values():
spine.set_color('#d1d5db')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Error Bar Chart examples
☕