The bar chart needs to be constructed with the entries of hist
centred on the corresponding bins, but the bins
array contains the bin boundaries:
In [x]: print(bins)
[ 0. 20. 40. 60. 80. 100.]
So construct an array containing the bin centres:
In [x]: bin_centres = (bins[:-1] + bins[1:])/2
In [x]: print(bin_centres)
[ 10. 30. 50. 70. 90.]
Then call plt.bar
specifying the width of each bin, and centering the bars on the values in bin_centres
:
In [x]: import matplotlib.pyplot as plt
In [x]: plt.bar(bin_centres, hist, width=20, align='center')