<p>我有计数数据(100个),每个对应一个箱子(0到99)。我需要把这些数据绘制成直方图。但是,柱状图计算这些数据并不能正确绘制,因为我的数据已经被装箱。</p>
<pre><code>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()
</code></pre>