If I use histogram of matplotlib , I can choose the number of bins. But how can I choose the number of bins at histogram of 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)
In this case range = number of bins = (12-1)+1 = 12
So the result is x = [ 1. 0. 1. 2. 0. 0. 0. 1. 1. 1. 0. 1.]
But the result of numpy is
hist, bin_edges = np.histogram(array, density=False)
numpy = [1 1 2 0 0 0 1 1 1 1] numpy_bin = [ 1. 2.1 3.2 4.3 5.4 6.5 7.6 8.7 9.8 10.9 12. ]
When using numpy , how can I choose the number of bins(= int((max(array)) - min(array))+1)
I want the same result like matplotlib