事后看来,解决方案非常简单明了。直方图对象只是每个 bin 出现的数组,所以我只取了直方图本身的 cumsum。
所以基本上
import histogram, numpy
y = range(0, 100) #Except I used real data
Hist = histogram(y, bins=100, range=[0,100])
colors = ['red', 'blue', 'green', ]
ranges = [[0,30], [30,31], [31,100]]
fig = pyplot.figure(figsize=(8,6))
ax, plt, _ = fig.plothist(Hist, alpha=0) # plot for spacing
for c, r in zip(colors, ranges):
plt = ax.overlay(Hist, range=r, facecolor=c)
print y
CumulativeHist = numpy.cumsum(h6)
colors = ['red', 'blue', 'green', ]
ranges = [[0,30], [30,31], [31,100]]
fig = pyplot.figure(figsize=(8,6))
ax, plt, _ = fig.plothist(CumulativeHist, alpha=0) # plot for spacing
for c, r in zip(colors, ranges):
plt = ax.overlay(CumulativeHist, range=r, facecolor=c)
pyplot.show()
会做两个情节,其中第二个是第二个的累积版本。谢谢您的帮助。
亚历克斯