曲线直方图,代表直方图趋势

时间:2019-03-30 10:38:26

标签: python histogram curve-fitting

我已经绘制了直方图,现在我想具有代表直方图趋势的曲线。我希望直方图合并是对数的(如我在下面的代码中所述;质量变量是预定义的变量,范围从10 ^ 43-10 ^ 45克)。

我寻找了很多代码,但其中的任何一个都不适合我的情况(也试图进行修改)。你知道我该怎么做吗?实际上,我只想修改代码,使其包括在直方图上方绘制此曲线。

谢谢

莎乐美

See the attached image

import matplotlib.pyplot as plt
import numpy as np
x=Mass
hist, bins = np.histogram(x, bins=10)
logbins = np.logspace(np.log10(bins[0]),np.log10(bins[-1]),len(bins))

n, bins, patches = plt.hist(x=Mass, bins=logbins, color='#0504aa', alpha=0.8, rwidth=0.85) 
plt.xscale('log')
plt.xlabel('Mass $(g)$ ')
plt.ylabel('Number of halos')
plt.show()

0 个答案:

没有答案