Line & Scatter
Bidirectional Error Bars
Error bars showing uncertainty in both X and Y directions.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# === STYLE CONFIG ===
COLORS = {
'points': '#8B5CF6',
'error': '#8B5CF6',
'background': '#FAFBFC',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#E2E8F0',
}
# === DATA ===
np.random.seed(42)
x = np.array([2, 4, 6, 8])
y = np.array([3, 5, 4, 6])
xerr = np.array([0.3, 0.5, 0.4, 0.6])
yerr = np.array([0.5, 0.7, 0.6, 0.8])
# === 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, xerr=xerr, yerr=yerr, fmt='D', color=COLORS['points'],
ecolor=COLORS['error'], elinewidth=2, capsize=5, capthick=2,
markersize=12, markeredgecolor='white', markeredgewidth=2,
alpha=0.9)
# === AXES ===
ax.set_xlim(0, 10)
ax.set_ylim(0, 8)
ax.set_xlabel('X Variable', fontsize=10, color=COLORS['text_muted'], labelpad=10)
ax.set_ylabel('Y Variable', 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.xaxis.grid(True, color=COLORS['grid'], linewidth=0.5, alpha=0.7)
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
More Line & Scatter examples
☕