stairs(values)
繪製一個階梯式常數函數作為線條或填充圖。
在繪製 \(y\) 介於 \((x_i, x_{i+1})\) 之間時,請參閱 stairs
。對於在 \(x\) 處繪製 \(y\),請參閱 step
。

import matplotlib.pyplot as plt
import numpy as np
plt.style.use('_mpl-gallery')
# make data
y = [4.8, 5.5, 3.5, 4.6, 6.5, 6.6, 2.6, 3.0]
# plot
fig, ax = plt.subplots()
ax.stairs(y, linewidth=2.5)
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
ylim=(0, 8), yticks=np.arange(1, 8))
plt.show()
由 Sphinx-Gallery 產生的圖庫