Line & Scatter
Continuous Error Band
Line plot with continuous shaded error band.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# === STYLE CONFIG ===
COLORS = {
'line': '#EC4899',
'band': '#EC4899',
'background': '#FAFBFC',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#E2E8F0',
}
# === DATA ===
x = np.linspace(0, 10, 50)
y = 3 + 2 * np.sin(x)
error = 0.3 + 0.2 * np.abs(np.sin(x * 2))
# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
# === PLOT ===
# Error band
ax.fill_between(x, y - error, y + error, color=COLORS['band'], alpha=0.2)
# Main line
ax.plot(x, y, color=COLORS['line'], linewidth=2.5)
# Sample points with error bars
sample_idx = [0, 12, 25, 37, 49]
ax.errorbar(x[sample_idx], y[sample_idx], yerr=error[sample_idx],
fmt='o', color=COLORS['line'], ecolor=COLORS['line'],
elinewidth=2, capsize=5, capthick=2, markersize=8,
markeredgecolor='white', markeredgewidth=2, zorder=5)
# === AXES ===
ax.set_xlim(0, 10)
ax.set_ylim(0, 6)
ax.set_xlabel('X', fontsize=10, color=COLORS['text_muted'], labelpad=10)
ax.set_ylabel('Y', 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
More Line & Scatter examples
☕