如果我使用matplotlib的直方图,我可以选择垃圾桶的数量。但是我如何选择numpy直方图中的仓位数呢?
import matplotlib.pyplot as plt
import numpy as np
array = [1,3,4,4,8,9,10,12]
range = int((max(array)) - min(array))+1
x, bins, patch = plt.hist(array, bins=range)在这种情况下,范围=箱数= ( 12 -1)+1 =12
所以结果是x=1.0。1.2.0。0。0。1. 1. 1. 0.1.
但是numpy的结果是
hist, bin_edges = np.histogram(array, density=False)numpy_bin = 1. 2.1 3.2 4.3 5.4 6.5 7.6 8.7 9.8 10.9 12.
使用numpy时,如何选择min个数(= int((max(array)) - min(array))+1)
我想要和matplotlib一样的结果
https://stackoverflow.com/questions/47607250
复制相似问题