The line of the line that you produce does not line up, since the x values used are the edges of the bin. You can calculate the centers of the bins as follows: bin_centers = 0.5*(x[1:]+x[:-1]) Then the full code:
noise = np.random.normal(0,1,(1000,1)) n,x,_ = plt.hist(noise, bins = np.linspace(-3,3,7), histtype=u'step' ) bin_centers = 0.5*(x[1:]+x[:-1]) plt.plot(bin_centers,n)
If you want the chart to be filled to y = 0, use plt.fill_between(bin_centers,n) 
Mattb source share