Error Bar Chart

Supplement Bioavailability Study

Absorption rate comparison between standard and liposomal supplement forms.

Output
Supplement Bioavailability Study
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

supplements = ['Vitamin D3', 'Vitamin C', 'Iron', 'Magnesium', 'B12', 'Omega-3']
standard = np.array([50, 70, 15, 35, 40, 25])
liposomal = np.array([90, 90, 45, 60, 85, 50])
standard_err = np.array([8, 10, 5, 6, 8, 5])
lipo_err = np.array([5, 6, 8, 7, 6, 6])

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

x = np.arange(len(supplements))
width = 0.35

ax.bar(x - width/2, standard, width, yerr=standard_err, label='Standard Form',
       color='#27D3F5', edgecolor='white', linewidth=1.5, capsize=5,
       error_kw={'ecolor': '#374151', 'elinewidth': 2})
ax.bar(x + width/2, liposomal, width, yerr=lipo_err, label='Liposomal Form',
       color='#F5276C', edgecolor='white', linewidth=1.5, capsize=5,
       error_kw={'ecolor': '#374151', 'elinewidth': 2})

ax.set_xlabel('Supplement', fontsize=12, color='#374151', fontweight='600')
ax.set_ylabel('Bioavailability (%)', fontsize=12, color='#374151', fontweight='600')
ax.set_title('Supplement Absorption: Standard vs Liposomal', fontsize=15, 
             color='#1f2937', fontweight='bold', pad=20)

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