scatter plot data does not appear on continents in 'hammer' basemap

帅比萌擦擦* 提交于 2019-11-28 13:46:30

You're probably missing the keyword to interpret lat-lon data as such. From the help for Basemap.scatter:

If latlon keyword is set to True, x,y are intrepreted as longitude and latitude in degrees. Data and longitudes are automatically shifted to match map projection region for cylindrical and pseudocylindrical projections, and x,y are transformed to map projection coordinates. If latlon is False (default), x and y are assumed to be map projection coordinates.

I also needed to increase the z-order to get scatter on top of the continents as well as the oceans.

import time, calendar, datetime, numpy
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# draw map with markers for float locations
m = Basemap(projection='hammer',lon_0=180)
m.drawmapboundary(fill_color='#99ffff')
m.fillcontinents(color='#cc9966',lake_color='#99ffff')

m.scatter([-73.98, 238., 0.08, 0., 116.38],[40.78,47.6,  51.53,0., 39.91],
          latlon=True, # Ta-da!
          marker='o',color='k',
          zorder=10)

plt.title('Hammer projection, data on top',fontsize=12)
plt.show()

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!