Error Bar Chart
Clinical Trial Treatment Response
Clinical trial comparison showing treatment vs placebo response rates over 24 weeks with confidence intervals.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
# Clinical trial data - drug efficacy over weeks
weeks = np.array([1, 2, 4, 8, 12, 16, 20, 24])
treatment = np.array([15, 28, 42, 58, 68, 74, 78, 80])
placebo = np.array([12, 14, 16, 18, 19, 20, 21, 21])
treatment_err = np.array([3, 4, 5, 6, 5, 4, 3, 3])
placebo_err = np.array([2, 2, 3, 3, 3, 3, 2, 2])
fig, ax = plt.subplots(figsize=(10, 6), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
# Plot with error bars
ax.errorbar(weeks, treatment, yerr=treatment_err, fmt='o-', color='#27D3F5',
ecolor='#27D3F5', elinewidth=1.5, capsize=4, capthick=1.5,
markersize=8, markerfacecolor='#27D3F5', markeredgecolor='white',
markeredgewidth=1, label='Treatment Group', linewidth=2, alpha=0.9)
ax.errorbar(weeks, placebo, yerr=placebo_err, fmt='s-', color='#F5276C',
ecolor='#F5276C', elinewidth=1.5, capsize=4, capthick=1.5,
markersize=7, markerfacecolor='#F5276C', markeredgecolor='white',
markeredgewidth=1, label='Placebo Group', linewidth=2, alpha=0.9)
ax.fill_between(weeks, treatment - treatment_err, treatment + treatment_err,
color='#27D3F5', alpha=0.1)
ax.fill_between(weeks, placebo - placebo_err, placebo + placebo_err,
color='#F5276C', alpha=0.1)
ax.set_xlabel('Weeks', fontsize=11, color='white', fontweight='500')
ax.set_ylabel('Response Rate (%)', fontsize=11, color='white', fontweight='500')
ax.set_title('Clinical Trial: Treatment vs Placebo Response', fontsize=14,
color='white', fontweight='bold', pad=15)
ax.legend(facecolor='#1a1a2e', edgecolor='#333', labelcolor='white', fontsize=10)
ax.tick_params(colors='#94a3b8', labelsize=9)
ax.set_xlim(0, 26)
ax.set_ylim(0, 100)
ax.grid(True, alpha=0.2, color='#4a4a6a')
for spine in ax.spines.values():
spine.set_color('#333333')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Error Bar Chart examples
☕