0

“m”是在https://www.dropbox.com/s/vua4nakd8sz3ocy/data.py?dl=0中定义的 GPS 坐标数组

我可以使用 matplotlib 函数

hist2d(zip(*m)[0],zip(*m)[1], bins=60, cmap='jet', normed=True)

生成正确的密度热图。

但是,如果我使用这种方式:

x,y = zip(*m)[:2]
heatmap, xedges, yedges = np.histogram2d(x,y,bins=50)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
clf()
scatter(x,y,c='k')
imshow(heatmap, extent=extent, cmap='jet')

它会产生明显错误的热图。为什么会这样?

错误的.img

黑点是 GPS 点。

4

1 回答 1

0

我想到了!numpy 中的 histogram2d 使用横坐标和纵坐标系,以便与 numpy 中的 histogramdd 保持一致。所以正确的应该是:

x,y = zip(*m)[:2]
heatmap, xedges, yedges = np.histogram2d(y,x,bins=40) 
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
scatter(x,y,c='k')
imshow(heatmap[::-1], extent=extent,cmap='jet',interpolation='nearest')

无论如何,不​​建议这样做。

于 2016-06-16T12:13:23.797 回答