python - 底图 m.scatter 不允许点出现在地图上并保留填充大陆颜色
问题描述
我有这个 Python 代码:
m = Basemap(projection='tmerc',
llcrnrlon=-10.56,
llcrnrlat=51.39,
urcrnrlon=-5.34,
urcrnrlat=55.43,
resolution='h',
epsg=29902)
# Fill the globe with blue color
m.drawmapboundary(fill_color='aqua')
# Draw country boundaries
m.drawcountries()
# Fill the continents with the land color
m.fillcontinents(color='coral', lake_color='aqua')
m.drawcoastlines()
lons = [-7.637558, -5.926437, -6.266155]
lats = [54.350155, 54.607868, 53.350140]
x, y = m(lons, lats)
m.scatter(x, y, marker='D', color='m')
plt.show()
当我运行它时,这些点不会出现在我的地图上。如果我添加它们zorder=0
,fillcontinents
它们确实会出现,但整个地图都是aqua
彩色的。如果我没有zorder=0
并且我使用m.plot
而不是m.scatter
绘制点,但它们之间会出现我不想要的线条。
如何让点自行出现但保留fillcontinents
颜色?
可能的解决方案
我添加zorder=2
到m.scatter
. 这是最 Pythonic 的方式吗?
m = Basemap(projection='tmerc',
llcrnrlon=-10.56,
llcrnrlat=51.39,
urcrnrlon=-5.34,
urcrnrlat=55.43,
resolution='h',
epsg=29902)
# Fill the globe with blue color
m.drawmapboundary(fill_color='aqua')
# Draw country boundaries
m.drawcountries()
# Fill the continents with the land color
m.fillcontinents(color='coral', lake_color='aqua')
m.drawcoastlines()
lons = [-7.637558, -5.926437, -6.266155]
lats = [54.350155, 54.607868, 53.350140]
x, y = m(lons, lats)
m.scatter(x, y, marker='D', color='m', zorder=2)
plt.show()
解决方案
我添加zorder=2
到m.scatter
. 这是最 Pythonic 的方式吗?
m = Basemap(projection='tmerc',
llcrnrlon=-10.56,
llcrnrlat=51.39,
urcrnrlon=-5.34,
urcrnrlat=55.43,
resolution='h',
epsg=29902)
# Fill the globe with blue color
m.drawmapboundary(fill_color='aqua')
# Draw country boundaries
m.drawcountries()
# Fill the continents with the land color
m.fillcontinents(color='coral', lake_color='aqua')
m.drawcoastlines()
lons = [-7.637558, -5.926437, -6.266155]
lats = [54.350155, 54.607868, 53.350140]
x, y = m(lons, lats)
m.scatter(x, y, marker='D', color='m', zorder=2)
plt.show()
推荐阅读
- python - 有返回问题的总和的所有路径
- web-component - 在 Lightning Web 组件中使用 Preact
- javascript - 未处理的拒绝 (TypeError):fs.readdir 不是函数
- https - 为 insecure-requests=redirect 更改 quarkus 安全端口
- c# - 将 .ToArray() 放入 from/in 时,LINQ 查询性能不佳
- amazon-web-services - 是否可以使用“HTTP”协议(而不是 REST)通过 AWS API Gateway 返回 HTML?
- ffmpeg - 无法使用 ffmpeg 播放录制的视频和音频
- sql - 如何使用 Vertica 将 IPv6 中的地址转换为数字
- spring - 如何使用 spring-authorization-server 在 JWT 中创建自定义声明
- typescript - 手动传递 3 个泛型中的 1 个并告诉编译器推断其余的