Python Numpy matplotlib Histograms 直方图

import numpy as np
import matplotlib.pyplot as plt 
mu,sigma = 2,0.5
v = np.random.normal(mu,sigma,10000)
plt.hist(v,bins=50,density=1)
plt.show()

import numpy as np
import matplotlib.pyplot as plt 
mu,sigma = 2,0.5
v = np.random.normal(mu,sigma,10000)
(n,bins) = np.histogram(v,bins=50,density=True)
plt.plot(.5*(bins[1:]+bins[:-1]),n)
plt.show()

posted @ 2018-09-13 13:27  vercont  阅读(172)  评论(0编辑  收藏  举报