Error Bar Chart

Daily Carbon Emissions by Diet

Daily CO2 emissions comparison across different dietary choices.

Output
Daily Carbon Emissions by Diet
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

diets = ['Vegan', 'Vegetarian', 'Pescatarian', 'Flexitarian', 'Omnivore', 'High Meat']
co2_kg = np.array([1.5, 2.5, 3.2, 4.0, 5.5, 7.2])
variability = np.array([0.3, 0.4, 0.5, 0.6, 0.8, 1.0])

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

x = np.arange(len(diets))
colors = ['#6CF527', '#27F5B0', '#27D3F5', '#F5D327', '#F5B027', '#F5276C']

bars = ax.bar(x, co2_kg, yerr=variability, capsize=6,
              color=colors, edgecolor='white', linewidth=2,
              error_kw={'ecolor': '#374151', 'elinewidth': 2, 'capthick': 2},
              alpha=0.9, width=0.65)

ax.set_xlabel('Diet Type', fontsize=12, color='#374151', fontweight='600')
ax.set_ylabel('CO₂ Emissions (kg/day)', fontsize=12, color='#374151', fontweight='600')
ax.set_title('Daily Carbon Emissions by Diet Type', fontsize=15, 
             color='#1f2937', fontweight='bold', pad=20)

ax.set_xticks(x)
ax.set_xticklabels(diets, fontsize=11, rotation=15, ha='right')
ax.tick_params(colors='#6b7280', labelsize=10)
ax.set_ylim(0, 9)
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