Histogram2D.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:WXMLTilingsHOWTO 作者: maxieds 项目源码 文件源码
def DensityHistogram(xypoints, numbins):

     xpoints = map(lambda (x, y): x, xypoints)
     ypoints = map(lambda (x, y): y, xypoints)
     minx, maxx, miny, maxy = min(xpoints), max(xpoints), \
                              min(ypoints), max(ypoints)
     xedges = np.arange(minx, maxx, (maxx - minx) / float(numbins))
     yedges = np.arange(miny, maxy, (maxy - miny) / float(numbins))
     H, xedges, yedges = np.histogram2d(ypoints, xpoints, bins = (xedges, yedges))

     fig = plt.figure(figsize=(7, 3))
     ax = fig.add_subplot(132)
     ax.set_title('pcolormesh: exact bin edges')
     X, Y = np.meshgrid(xedges, yedges)
     ax.pcolormesh(X, Y, H)
     ax.set_aspect('equal')
     #plt.savefig('./output/foo.png', bbox_inches='tight')
     #plt.show()

     g = histogram([xpoints, ypoints])
     g.save('./output/foo2.png')

## def
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号