Error Bar Chart

Coffee Bean Cupping Scores

Specialty coffee bean quality comparison using professional cupping scores.

Output
Coffee Bean Cupping Scores
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

# Coffee bean scoring data
attributes = ['Aroma', 'Flavor', 'Aftertaste', 'Acidity', 'Body', 'Balance']
ethiopian = np.array([8.5, 8.8, 8.2, 8.6, 7.8, 8.4])
colombian = np.array([8.2, 8.4, 8.0, 8.0, 8.5, 8.3])
brazilian = np.array([7.8, 8.0, 7.6, 7.5, 8.8, 8.0])
err = np.array([0.3, 0.25, 0.35, 0.3, 0.25, 0.3])

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

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

ax.bar(x - width, ethiopian, width, yerr=err, label='Ethiopian Yirgacheffe',
       color='#F5276C', edgecolor='#1f2937', capsize=3,
       error_kw={'ecolor': '#374151', 'elinewidth': 1.5})
ax.bar(x, colombian, width, yerr=err, label='Colombian Supremo',
       color='#F5B027', edgecolor='#1f2937', capsize=3,
       error_kw={'ecolor': '#374151', 'elinewidth': 1.5})
ax.bar(x + width, brazilian, width, yerr=err, label='Brazilian Santos',
       color='#27D3F5', edgecolor='#1f2937', capsize=3,
       error_kw={'ecolor': '#374151', 'elinewidth': 1.5})

ax.axhline(y=8.0, color='#6CF527', linestyle='--', linewidth=1.5, 
           label='Specialty Grade (8.0)', alpha=0.7)

ax.set_xlabel('Attribute', fontsize=11, color='#374151', fontweight='500')
ax.set_ylabel('Cupping Score', fontsize=11, color='#374151', fontweight='500')
ax.set_title('Specialty Coffee Bean Cupping Scores', fontsize=14, 
             color='#1f2937', fontweight='bold', pad=15)

ax.set_xticks(x)
ax.set_xticklabels(attributes)
ax.legend(facecolor='#f8fafc', edgecolor='#d1d5db', fontsize=9, loc='lower right')
ax.tick_params(colors='#6b7280', labelsize=9)
ax.set_ylim(6.5, 9.5)
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

Did this help you?

Support PyLucid to keep it free & growing

Support