If I define a set of (geo)axes with a given height and width how can I make sure that the plot will fill these axes?
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
ax = plt.axes([0.3, 0.1, 0.4, 0.8], projection=ccrs.PlateCarree())
ax.coastlines()
ax.set_global()
plt.show()
This produces a plot with a sensible aspect ratio for the map, but I wanted it to fill the axes instead, resulting in a plot taller than it is wide. This is just an example, but there are real-world scenarios where doing this is important.
Edit
Just to calrify, I actually want the result to be distorted, so in my example I genuinely want a map with global extent that is taller than it is wide. Using ax.set_aspect('auto')
appears to work for PlateCarree
and NorthPolarStereographic
projections, but perhaps does not work for all (OSGB
for example).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…