1
目前在单个直方图中有3组数据,但我需要为每组数据绘制一条曲线。目前通过函数绘制直方图:Matplotlib:使用直方图数据绘制曲线
def plot_histogram(xmin,xmax,title,xlabel,data,data1,data2):
plt.xlim(xmin, xmax)
plt.title(title)
plt.xlabel(xlabel)
plt.ylabel('Relative Frequency')
bins=np.histogram(np.hstack((data,data1,data2)), bins=11)[1]
plt.hist([data, data1, data2], bins, normed=1, alpha=0.5, color=['b', 'g', 'r'], label=['t', 'g-', 'g+'])
plt.legend(loc='upper right')
plt.show()
如何绘制每个直方图形状的曲线或线?
你可能想看看核密度估计(KDE)。在我看来,'熊猫'是绘制KDE的最简单方法。 – cel 2015-02-24 17:50:42
我一直在研究KDE,我发现这个资源应该有所帮助(http://nbviewer.ipython.org/github/mwaskom/seaborn/blob/master/examples/plotting_distributions.ipynb),但不幸的是,seaborn赢得了'安装在我的电脑上。 你有没有其他的指针? – Charlietrypsin 2015-02-25 18:30:31