heatmap.py 文件源码

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

项目:Examples-using-TableauSDK 作者: sarahbat 项目源码 文件源码
def heatmap (d, bins=(100, 100), smoothing=1.3, cmap='jet'):
  def getx (pt):
    return pt.coords[0][0]

  def gety (pt):
    return pt.coords[0][1]

  x = list(d.geometry.apply(getx))
  y = list(d.geometry.apply(gety))
  heatmap, xedges, yedges = np.histogram2d(y, x, bins=bins)
  extent = [yedges[0], yedges[-1], xedges[-1], xedges[0]]  # bin edges along the x and y dimensions, ordered

  # why are we taking log?
  logheatmap = np.log(heatmap)
  logheatmap[np.isneginf(logheatmap)] = 0
  logheatmap = ndimage.filters.gaussian_filter(logheatmap, smoothing, mode='nearest')


  return (logheatmap, extent)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号