我有这段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
点被绘制,但线出现在他们之间whic我不想要。
我怎样才能让点在它们之间出现,但又能保留 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()