用正交投影再现卡普图的范围

Reproducing extent of cartopy plots with orthographic projection

我正在生成一组不同的地图,我希望它们都具有相同的轴限制。但是,我很难弄清楚如何设置范围。

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

lon = -90
lat = 90
proj =  ccrs.Orthographic

projection = proj(lon, lat)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection = projection)

transform = ccrs.Geodetic()

lat0 = 50
lon0 = 50

for x in range(-5,6):
    plt.plot(lon0 + x, lat0, 'bo', transform = transform)
    plt.plot(lon0, lat0 + x, 'bo', transform = transform)

我希望能够提取“地图”的范围,然后将其应用于将以不同方式自动缩放的其他地图。但是,即使我尝试提取范围并将其重新应用于同一图形,它也会失败。

a = ax.get_extent(crs = proj())
#a = (2769836.95350539, 3487499.8040009444, 4467034.2547478145, 5254224.255689873)
ax.set_extent(a, crs = proj())

理解后有点明显,但是需要在范围描述中指定投影的lonlat

a = ax.get_extent(crs = proj(lon, lat))
ax.set_extent(a, crs = proj(lon, lat))