Error Bar Chart

Probiotic Strain Health Benefits

Clinical effectiveness of different probiotic strains for health benefits.

Output
Probiotic Strain Health Benefits
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)

strains = ['L. acidophilus', 'B. lactis', 'L. rhamnosus', 'S. boulardii', 'L. plantarum']
gut_health = np.array([85, 78, 88, 72, 82])
immune = np.array([72, 80, 75, 65, 78])
digestion = np.array([90, 85, 82, 88, 75])
err = np.array([6, 7, 5, 8, 6])

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

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

ax.bar(x - width, gut_health, width, yerr=err, label='Gut Microbiome',
       color='#6CF527', edgecolor='white', linewidth=1.5, capsize=4,
       error_kw={'ecolor': '#374151', 'elinewidth': 1.5})
ax.bar(x, immune, width, yerr=err, label='Immune Support',
       color='#F5276C', edgecolor='white', linewidth=1.5, capsize=4,
       error_kw={'ecolor': '#374151', 'elinewidth': 1.5})
ax.bar(x + width, digestion, width, yerr=err, label='Digestive Health',
       color='#27D3F5', edgecolor='white', linewidth=1.5, capsize=4,
       error_kw={'ecolor': '#374151', 'elinewidth': 1.5})

ax.set_xlabel('Probiotic Strain', fontsize=12, color='#374151', fontweight='600')
ax.set_ylabel('Effectiveness Score', fontsize=12, color='#374151', fontweight='600')
ax.set_title('Probiotic Strain Health Benefits', fontsize=15, 
             color='#1f2937', fontweight='bold', pad=20)

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