/    /  NumPy – Histogram Using Matplotlib

NumPy – Histogram Using Matplotlib:

histogram: This will return the computed histogram of a set of data.

This function mainly works with bins and set of data given as input. Numpy histogram function will give the computed result as the occurances of input data which fall in each of the particular range of bins. That determines the range of area of each bar when plotted using matplotlib.

Example:

>>> import numpy as np

>>> np.histogram([10,15,16,24,25,45,36,45], bins=[0,10,20,30,40,50])
(array([0, 3, 2, 1, 2], dtype=int32), array([ 0, 10, 20, 30, 40, 50]))

>>> import matplotlib.pyplot as plt

>>> plt.hist([10,15,16,24,25,45,36,45], bins=[0,10,20,30,40,50])
(array([ 0., 3., 2., 1., 2.]), array([ 0, 10, 20, 30, 40, 50]), <a list of 5 Patch objects>)

>>> plt.show()