用cartopy绘制大圆路径

drawing great circle path with cartopy

我应该使用 cartopy 绘制地图。作业是:

使用正投影,以汉堡为中心,画出汉堡到东京的大圆路径

import cartopy
import cartopy.crs as ccrs

ax = plt.axes(projection=ccrs.Orthographic(central_longitude = long_ham, central_latitude = lat_ham))
ax.coastlines()


long_ham, lat_ham = 9.993682, 53.551086
long_tok, lat_tok = 139.839478, 35.652832

plt.plot([long_ham, long_tok], [lat_ham, lat_tok],
         color='blue', linewidth=2, marker='o',
         transform=ccrs.Geodetic(),
         )

plt.text(long_ham , lat_ham , 'Hamburg',
         horizontalalignment='right',
         transform=ccrs.Geodetic())

plt.text(long_tok , lat_tok , 'Tokyo',
         horizontalalignment='left',
         transform=ccrs.Geodetic())

# Save the plot by calling plt.savefig() BEFORE plt.show()
plt.savefig('great circle distance.pdf')
plt.savefig('great circle distance.png')

plt.show()

有没有办法显示整个地球,而不是我目前得到的特写?

您需要在savefig()plt.show()之前设置ax.set_global()