fig = plt.figure()
ax1 = fig.add_subplot(121)
n, bins, patches = ax1.hist(y, bins=50)
bins_mean = [(0.5 * (bins[i] + bins[i + 1])) for i in range(len(n))]
ax2 = fig.add_subplot(122)
ax2.scatter(bins_mean, n)
How to plot a scatter plot using the histogram output in matplotlib?