Basemap m.散布不允许点出现在地图上并保留填充颜色

2024-06-26 15:01:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下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颜色

可能的解决方案

我在{}中添加了{}。这是做这件事最像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', zorder=2)

plt.show()

Tags: thewithfillcolorbasemapaquaprojectionscatter
1条回答
网友
1楼 · 发布于 2024-06-26 15:01:26

我在{}中添加了{}。这是做这件事最像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', zorder=2)

plt.show()

相关问题 更多 >