Matplotlib histogram from numpy histogram output [duplicate] Matplotlib histogram from numpy histogram output [duplicate] numpy numpy

Matplotlib histogram from numpy histogram output [duplicate]


You can plot the output of numpy.histogram using plt.bar.

import matplotlib.pyplot as pltimport numpy as np; np.random.seed(1)a = np.random.rayleigh(scale=3,size=100)bins = np.arange(10)frq, edges = np.histogram(a, bins)fig, ax = plt.subplots()ax.bar(edges[:-1], frq, width=np.diff(edges), edgecolor="black", align="edge")plt.show()

enter image description here