Line & Scatter

Asymmetric Error Bars

Error bars with different upper and lower uncertainty bounds.

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

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

# === DATA ===
x = np.array([1, 2, 3, 4, 5])
y = np.array([2.5, 4.0, 3.5, 5.5, 6.0])
yerr_lower = np.array([0.3, 0.4, 0.5, 0.3, 0.4])
yerr_upper = np.array([0.8, 1.0, 0.7, 1.2, 0.9])

# === 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_lower, yerr_upper], fmt='o', 
            color=COLORS['points'], ecolor=COLORS['error'],
            elinewidth=2, capsize=6, capthick=2,
            markersize=12, markeredgecolor='white', markeredgewidth=2)

# Annotations
for xi, yi, lo, hi in zip(x, y, yerr_lower, yerr_upper):
    ax.annotate('+{:.1f}/-{:.1f}'.format(hi, lo), xy=(xi, yi + hi + 0.3),
                ha='center', fontsize=8, color=COLORS['text_muted'])

# === AXES ===
ax.set_xlim(0, 6)
ax.set_ylim(0, 8)
ax.set_xlabel('Sample', fontsize=10, color=COLORS['text_muted'], labelpad=10)
ax.set_ylabel('Measurement', 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