底图 m.scatter 不允许点出现在地图上并保留 fillcontinents 颜色
Basemap m.scatter not allowing points to appear on map and retain fillcontinents color
我有这个 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 代码:
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()