Line & Scatter

Classic Error Bars

Simple vertical error bars showing measurement uncertainty.

Output
Classic Error Bars
Python
import matplotlib.pyplot as plt
import numpy as np

# === STYLE CONFIG ===
COLORS = {
    'points': '#6366F1',
    'error': '#6366F1',
    'background': '#FAFBFC',
    'text': '#1E293B',
    'text_muted': '#64748B',
    'grid': '#E2E8F0',
}

# === DATA ===
np.random.seed(1)
x = np.array([1, 2, 3, 4, 5, 6, 7])
y = np.array([2.1, 3.4, 4.2, 5.8, 5.2, 6.1, 7.3])
yerr = np.array([0.4, 0.6, 0.5, 0.8, 0.7, 0.5, 0.6])

# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])

# === PLOT ===
ax.errorbar(x, y, yerr=yerr, fmt='o', color=COLORS['points'],
            ecolor=COLORS['error'], elinewidth=2, capsize=6, capthick=2,
            markersize=10, markeredgecolor='white', markeredgewidth=2)

# === AXES ===
ax.set_xlim(0, 8)
ax.set_ylim(0, 9)
ax.set_xlabel('Sample', fontsize=10, color=COLORS['text_muted'], labelpad=10)
ax.set_ylabel('Value', fontsize=10, color=COLORS['text_muted'], labelpad=10)

# === 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=0.5, alpha=0.7)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Pairwise Data

Did this help you?

Support PyLucid to keep it free & growing

Support