【发布时间】:2012-08-31 11:24:23
【问题描述】:
我有计数数据(其中 100 个),每个数据对应一个 bin(0 到 99)。我需要将这些数据绘制为直方图。但是,直方图计算了这些数据并且无法正确绘制,因为我的数据已经被分箱了。
import random
import matplotlib.pyplot as plt
x = random.sample(range(1000), 100)
xbins = [0, len(x)]
#plt.hist(x, bins=xbins, color = 'blue')
#Does not make the histogram correct. It counts the occurances of the individual counts.
plt.plot(x)
#plot works but I need this in histogram format
plt.show()
【问题讨论】:
标签: python plot matplotlib histogram