Error Bar Chart
Fertilizer Effect on Growth
Plant growth study comparing organic vs synthetic fertilizers against control group.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
# Fertilizer trial data
weeks = np.arange(1, 9)
organic = np.array([2.5, 4.2, 6.8, 10.2, 14.5, 18.8, 22.5, 25.8])
synthetic = np.array([3.8, 7.5, 12.5, 17.8, 22.5, 26.2, 28.8, 30.2])
control = np.array([2.2, 3.5, 5.2, 7.5, 10.2, 12.8, 15.2, 17.5])
org_err = np.array([0.5, 0.8, 1.2, 1.5, 1.8, 2.0, 2.2, 2.4])
syn_err = np.array([0.6, 1.0, 1.5, 2.0, 2.4, 2.6, 2.8, 3.0])
ctrl_err = np.array([0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.5, 1.6])
fig, ax = plt.subplots(figsize=(10, 6), facecolor='#ffffff')
ax.set_facecolor('#ffffff')
ax.errorbar(weeks, organic, yerr=org_err, fmt='o-', color='#6CF527',
ecolor='#6CF527', elinewidth=1.5, capsize=4, markersize=8,
markeredgecolor='#1f2937', linewidth=2, label='Organic', alpha=0.9)
ax.fill_between(weeks, organic - org_err, organic + org_err,
color='#6CF527', alpha=0.15)
ax.errorbar(weeks, synthetic, yerr=syn_err, fmt='s-', color='#4927F5',
ecolor='#4927F5', elinewidth=1.5, capsize=4, markersize=8,
markeredgecolor='#1f2937', linewidth=2, label='Synthetic', alpha=0.9)
ax.fill_between(weeks, synthetic - syn_err, synthetic + syn_err,
color='#4927F5', alpha=0.15)
ax.errorbar(weeks, control, yerr=ctrl_err, fmt='^--', color='#9ca3af',
ecolor='#9ca3af', elinewidth=1.5, capsize=4, markersize=7,
markeredgecolor='#1f2937', linewidth=2, label='Control (no fertilizer)', alpha=0.9)
ax.set_xlabel('Week', fontsize=11, color='#374151', fontweight='500')
ax.set_ylabel('Plant Height (cm)', fontsize=11, color='#374151', fontweight='500')
ax.set_title('Fertilizer Effect on Plant Growth', fontsize=14,
color='#1f2937', fontweight='bold', pad=15)
ax.legend(facecolor='#f8fafc', edgecolor='#d1d5db', fontsize=10)
ax.tick_params(colors='#6b7280', labelsize=9)
ax.set_xlim(0, 9)
ax.set_ylim(0, 38)
ax.grid(True, 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
☕