Stem Plot
Gradient Stem
Symmetrical stem with color gradient.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# === STYLE CONFIG ===
COLORS = {
'gradient': ['#6366F1', '#818CF8', '#A5B4FC', '#C7D2FE', '#E0E7FF',
'#E0E7FF', '#C7D2FE', '#A5B4FC', '#818CF8', '#6366F1'],
'background': '#FFFFFF',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#F1F5F9',
}
# === DATA ===
x = np.arange(1, 11)
y = [3, 5, 7, 8, 9, 8, 7, 5, 3, 2]
# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
# === PLOT ===
for xi, yi, c in zip(x, y, COLORS['gradient']):
# Glow
ax.scatter(xi, yi, s=200, c=c, alpha=0.2, zorder=2)
# Stem
ax.plot([xi, xi], [0, yi], color=c, linewidth=3, alpha=0.8, zorder=3)
# Marker
ax.scatter(xi, yi, s=100, c=c, edgecolors='white', linewidths=2, zorder=4)
ax.axhline(0, color=COLORS['text'], linewidth=1, zorder=1)
# === 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, zorder=0)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_xlim(0, 11)
ax.set_ylim(0, 11)
ax.set_xlabel('Position', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Amplitude', fontsize=10, color=COLORS['text'], labelpad=10)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Basic Charts
More Stem Plot examples
☕