Line & Scatter
Horizontal Error Bars
Error bars showing uncertainty in the X direction.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# === STYLE CONFIG ===
COLORS = {
'points': '#10B981',
'error': '#10B981',
'background': '#FAFBFC',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#E2E8F0',
}
# === DATA ===
np.random.seed(42)
x = np.array([2, 4, 6, 8, 10])
y = np.array([1, 2, 3, 4, 5])
xerr = np.array([0.5, 0.8, 0.6, 1.0, 0.7])
# === 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, fmt='s', color=COLORS['points'],
ecolor=COLORS['error'], elinewidth=2, capsize=5, capthick=2,
markersize=10, markeredgecolor='white', markeredgewidth=2)
# === AXES ===
ax.set_xlim(0, 12)
ax.set_ylim(0, 6)
ax.set_xlabel('Measurement', fontsize=10, color=COLORS['text_muted'], labelpad=10)
ax.set_ylabel('Category', 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.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
☕