Bar Chart
Time Course with Error
Grouped bars showing progression with significance stars.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# === STYLE CONFIG ===
COLORS = {
'group1': '#3B82F6',
'group2': '#10B981',
'background': '#FFFFFF',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#F1F5F9',
'significant': '#EF4444',
}
# === DATA ===
categories = ['Day 1', 'Day 3', 'Day 7', 'Day 14']
group1_means = [25, 45, 68, 82]
group1_err = [4, 5, 6, 5]
group2_means = [22, 38, 55, 60]
group2_err = [3, 4, 5, 6]
significant = [False, False, True, True]
x = np.arange(len(categories))
width = 0.35
# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
# === PLOT ===
# Group 1
bars1 = ax.bar(x - width/2, group1_means, width*0.85, color=COLORS['group1'],
alpha=0.85, edgecolor='white', linewidth=1.5, label='Treatment', zorder=3)
ax.errorbar(x - width/2, group1_means, yerr=group1_err, fmt='none',
ecolor=COLORS['text'], elinewidth=1.5, capsize=4, capthick=1.5, zorder=4)
# Group 2
bars2 = ax.bar(x + width/2, group2_means, width*0.85, color=COLORS['group2'],
alpha=0.85, edgecolor='white', linewidth=1.5, label='Control', zorder=3)
ax.errorbar(x + width/2, group2_means, yerr=group2_err, fmt='none',
ecolor=COLORS['text'], elinewidth=1.5, capsize=4, capthick=1.5, zorder=4)
# Significance stars
for i, sig in enumerate(significant):
if sig:
max_y = max(group1_means[i] + group1_err[i], group2_means[i] + group2_err[i])
ax.text(i, max_y + 5, '*', ha='center', fontsize=16,
fontweight='bold', color=COLORS['significant'])
# === STYLING ===
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color(COLORS['grid'])
ax.spines['bottom'].set_color(COLORS['grid'])
ax.yaxis.grid(True, color=COLORS['grid'], linewidth=1, zorder=0)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_xticks(x)
ax.set_xticklabels(categories)
ax.set_ylim(0, 110)
ax.set_ylabel('Expression Level', fontsize=10, color=COLORS['text'], labelpad=10)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12),
ncol=2, frameon=False, fontsize=9, labelcolor=COLORS['text_muted'])
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Basic Charts
More Bar Chart examples
☕