如何更正此代码以将点放在地图的右侧?

How to correct this code to place the points on the right part of the map?

我想在底图上绘制散点图,我的代码是这样的: %matplotlib 内联 来自 mpl_toolkits.basemap 导入底图

创建图形和轴

fig = plt.figure(figsize=(20, 10))

m = Basemap(projection='lcc', resolution='h', \
    lat_0=51.53, lon_0=0.08,
    width=1E6, height=1.2E6)
m.shadedrelief()
m.drawcoastlines(color='gray')
m.drawcountries(color='gray')


y,x = m(dfrt['lon'].values, dfrt['lat'].values)
m.scatter(x,y, marker="o", color='g', alpha=0.7, zorder=5)

plt.title("Localización de los Bikepoints")
plt.show()

dfrt 是这个数据框:

commonName  id  lat lon placeType   url additionalProperties2   category    key sourceSystemKey value   modified
0   River Street , Clerkenwell  BikePoints_1    51.529163   -0.109970   BikePoint   /Place/BikePoints_1 {'$type': 'Tfl.Api.Presentation.Entities.Addit...   Description TerminalName    BikePoints  001023  2019-08-22T11:17:04.327Z
1   Phillimore Gardens, Kensington  BikePoints_2    51.499606   -0.197574   BikePoint   /Place/BikePoints_2 {'$type': 'Tfl.Api.Presentation.Entities.Addit...   Description TerminalName    BikePoints  001018  2019-08-22T11:10:02.34Z
2   Christopher Street, Liverpool Street    BikePoints_3    51.521283   -0.084605   BikePoint   /Place/BikePoints_3 {'$type': 'Tfl.Api.Presentation.Entities.Addit...   Description TerminalName    BikePoints  001012  2019-08-22T11:12:02.7Z
3   St. Chad's Street, King's Cross BikePoints_4    51.530059   -0.120973   BikePoint   /Place/BikePoints_4 {'$type': 'Tfl.Api.Presentation.Entities.Addit...   Description TerminalName    BikePoints  001013  2019-08-22T11:08:02.047Z
4   Sedding Street, Sloane Square   BikePoints_5    51.493130   -0.156876   BikePoint   /Place/BikePoints_5 {'$type': 'Tfl.Api.Presentation.Entities.Addit...   Description TerminalName    BikePoints  003420  2019-08-22T11:14:02.787Z

但是我得到的情节不正确,绿点应该在伦敦:

有什么想法吗?谢谢!!

你打错了:

y,x = m(dfrt['lon'].values, dfrt['lat'].values)

应该读作:

x,y = m(dfrt['lon'].values, dfrt['lat'].values)

根据 Matplotlib 文档: matplotlib basemap

这是您预期的结果:

看起来你的 x 和 y 颠倒了。尝试更改

y,x = m(dfrt['lon'].values, dfrt['lat'].values)

x,y = m(dfrt['lon'].values, dfrt['lat'].values)