从^{}的文档中:Returns
n : array or list of arrays
The values of the histogram bins. See normed and weights for a description of the possible semantics. If input x is an array, then this is an array of length nbins. If input is a sequence arrays [data1, data2,..], then this is a list of arrays with the values of the histograms for each of the arrays in the same order.
bins : array
The edges of the bins. Length nbins + 1 (nbins left edges and right edge of last bin). Always a single array even when multiple data sets are passed in.
patches : list or list of lists
Silent list of individual patches used to create the histogram or list of such list if multiple input datasets.
正如您所看到的,第二个返回实际上是容器的边缘,因此它包含的项目比容器多一个。
获得垃圾箱中心的最简单方法是:import numpy as np
bin_center = bin_borders[:-1] + np.diff(bin_borders) / 2
它只是将两个边框之间的一半宽度(带^{})添加到左边的边框(