我有两组数据,分别使用http://matplotlib.org/examples/pylab_examples/hist2d_log_demo.html中的matplotlib的hist2d()从中绘制2D直方图。现在,我想获得这两个2D直方图的比率(即频率的比率)。如何在matplotlib中实现此目标?
内部 hist2d
使用numpy.histogram2d
。因此,你可以计算出使用该功能既直方图,计算比率,然后用它绘制pcolormesh
,imshow
或类似的。
h1, xedges, yedges = np.histogram2d(x1, y1, bins=bins)
h2, xedges, yedges = np.histogram2d(x2, y2, bins=bins)
h = h1 / h2
pc = ax.pcolorfast(xedges, yedges, h.T)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句