Stairs Plot
Temperature Zones
Room temperature with comfort zones.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
COLORS = {'temp': '#6366F1', 'comfort': '#10B981', 'background': '#FFFFFF', 'text': '#1E293B', 'text_muted': '#64748B', 'grid': '#F1F5F9'}
hours = np.arange(24)
temp = [18, 17, 17, 16, 16, 17, 19, 21, 22, 23, 24, 24, 25, 25, 24, 23, 22, 21, 20, 20, 19, 19, 18, 18]
edges = np.arange(25)
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
# Comfort zone
ax.axhspan(20, 24, alpha=0.15, color=COLORS['comfort'], label='Comfort Zone')
ax.stairs(temp, edges, fill=True, alpha=0.2, facecolor=COLORS['temp'])
ax.stairs(temp, edges, linewidth=2.5, color=COLORS['temp'], label='Temperature')
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, 24)
ax.set_ylim(14, 28)
ax.set_xticks([0, 6, 12, 18, 24])
ax.set_xticklabels(['12AM', '6AM', '12PM', '6PM', '12AM'])
ax.set_ylabel('Temperature (°C)', fontsize=10, color=COLORS['text'], labelpad=10)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12), ncol=2, frameon=False, fontsize=9, labelcolor=COLORS['text_muted'])
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Basic Charts
More Stairs Plot examples
☕