我想使用 Python 和 Matplotlib 根据数组中的值创建直方图,而不是根据数组中的值的计数。例如:-
X = [0,0,0,1,10,5,0,0,5]
如果我使用下面的代码
n, bins, patches = plt.hist(X) plt.show()
我得到这个直方图
这是计算出现次数并创建直方图。输出应该是这样的:- 预期情节
python matplotlib histogram
histogram ×1
matplotlib ×1
python ×1