我有计数数据(共100个),每个对应一个箱子(从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()