Scatter Plot

Error Bar Scatter

Scatter plot with X and Y error bars for uncertainty.

Output
Error Bar Scatter
Python
import matplotlib.pyplot as plt
import numpy as np

# === STYLE CONFIG ===
COLORS = {
    'primary': '#3B82F6',
    'error': '#3B82F6',
    'background': '#FFFFFF',
    'text': '#1E293B',
    'text_muted': '#64748B',
    'grid': '#F1F5F9',
}

# === DATA ===
np.random.seed(42)
x = np.arange(1, 11)
y = 2 * x + 5 + np.random.normal(0, 2, 10)
x_err = np.random.uniform(0.2, 0.5, 10)
y_err = np.random.uniform(1, 3, 10)

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

# === PLOT ===
# Error bars
ax.errorbar(x, y, xerr=x_err, yerr=y_err, fmt='none',
            ecolor=COLORS['error'], elinewidth=1.5, capsize=4, 
            capthick=1.5, alpha=0.5, zorder=1)

# Points with glow
ax.scatter(x, y, s=200, c=COLORS['primary'], alpha=0.15, zorder=2)
ax.scatter(x, y, s=80, c=COLORS['primary'], alpha=0.9,
           edgecolors='white', linewidths=2, zorder=3)

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

ax.set_xlabel('Measurement', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Value ± Error', fontsize=10, color=COLORS['text'], labelpad=10)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Pairwise Data

Did this help you?

Support PyLucid to keep it free & growing

Support