I am generating set of different maps and I would like them to all have the same axis limits. However, I am having a hard time figuring out how to set the extent.
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)
I want to be able to extract the extent of the "map" and then apply it to other maps that will autoscale differently. However, even when I try to extract the extent and reapply it to the same figure, it fails.
a = ax.get_extent(crs = proj())
#a = (2769836.95350539, 3487499.8040009444, 4467034.2547478145, 5254224.255689873)
ax.set_extent(a, crs = proj())
Kind of obvious once I realized it, but the lon
and lat
of projection need to be specified in the extent description.
a = ax.get_extent(crs = proj(lon, lat))
ax.set_extent(a, crs = proj(lon, lat))