散点图数据未出现在“锤"底图中的各大洲上 [英] scatter plot data does not appear on continents in 'hammer' basemap

查看:54
本文介绍了散点图数据未出现在“锤"底图中的各大洲上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用散点图在锤"底图上绘制数据集.但是,这些数据点不会在各大洲之上绘制.我在matplotlib 示例中注意到,各大洲也没有数据(我以为这是取决于示例的性质).我想知道我是在做错什么,还是无法通过设计使用锤子"将数据绘制在各大洲的顶部.

I am attempting to plot a dataset over the 'hammer' basemap using a scatter plot. However, the data points won't plot on top of the continents. I noticed in the matplotlib example, there is also not data on the continents (I assumed this was due to the nature of the example). I'm wondering if I'm doing something wrong, or if data cannot be plotted on top of the continents using 'hammer' by design.

如果是这种情况,是否有理想的底图可用于在整个地球上绘制散点图数据(使用浮雕图会很好,但是我现在会解决任何问题)?

If this is the case, is there an ideal basemap to use to plot scatter plot data over the whole Earth (using a relief map would be great, but I would settle for anything at this point)?

推荐答案

您可能缺少用于解释lat-lon数据的关键字.从Basemap.scatter的帮助中:

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

如果latlon关键字设置为True,则将x,y解释为经度 和纬度(度).数据和经度是自动的 移位以匹配圆柱体和 伪圆柱投影和x,y转换为贴图 投影坐标.如果latlon为False(默认),则x和y为 假定为地图投影坐标.

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.

我还需要增加z轴的阶数,以分散到各大洲以及海洋的顶部.

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

这篇关于散点图数据未出现在“锤"底图中的各大洲上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆