Stem Plot
Range Stem Plot
Daily temperature range with min/mid/max markers.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
COLORS = {
'stem': '#10B981',
'range': '#10B981',
'background': '#FFFFFF',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#F1F5F9',
}
x = np.arange(1, 8)
mid = [50, 55, 48, 62, 58, 52, 60]
low = [45, 48, 42, 55, 52, 46, 54]
high = [55, 62, 55, 68, 65, 58, 66]
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
for xi, l, m, h in zip(x, low, mid, high):
# Range line
ax.plot([xi, xi], [l, h], color=COLORS['range'], linewidth=4, alpha=0.3, zorder=2)
# Stem to zero
ax.plot([xi, xi], [0, l], color=COLORS['stem'], linewidth=2, alpha=0.5, zorder=2)
# Markers
ax.scatter(xi, m, s=100, c=COLORS['stem'], edgecolors='white', linewidths=2, zorder=4)
ax.scatter(xi, l, s=50, c=COLORS['stem'], alpha=0.6, zorder=3)
ax.scatter(xi, h, s=50, c=COLORS['stem'], alpha=0.6, zorder=3)
ax.axhline(0, color=COLORS['text'], linewidth=1, zorder=1)
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, 8)
ax.set_ylim(0, 75)
ax.set_xticks(x)
ax.set_xticklabels(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'])
ax.set_ylabel('Temperature (°F)', fontsize=10, color=COLORS['text'], labelpad=10)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Basic Charts
More Stem Plot examples
☕