0

"m" is an GPS coordinates array defined in https://www.dropbox.com/s/vua4nakd8sz3ocy/data.py?dl=0

I can use the matplotlib function

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

to produce the correct density heatmap.

However, if I use this way:

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')

It produces the obviously wrong heatmap. Why this happen?

wrong.img

The black points are the GPS points.

tonny2v
  • 11
  • 1

1 Answers1

0

I figured it out! histogram2d in numpy uses abscissa and ordinate system in order to be consistent with histogramdd in numpy. So the correct one should be:

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')

Anyway, this is not recommended.

tonny2v
  • 11
  • 1