mad*_*ast 16 python numpy matplotlib scipy
我正在尝试获取已经分箱数据的直方图.我一直在尝试使用bar()它,但我似乎无法弄清楚如何使它成为像这样的阶梯式直方图,而不是填充的直方图.

您可以通过抵消数据并使用以下方式作弊plot:
from matplotlib import pyplot
import numpy as np
#sample data:
x = np.arange(30)
y = np.cumsum(np.arange(30))
#offset the x for horizontal, repeat the y for vertical:
x = np.ravel(zip(x,x+1))
y = np.ravel(zip(y,y))
pyplot.plot(x,y)
pyplot.savefig('plt.png')
Run Code Online (Sandbox Code Playgroud)
剧情:
