Assume I need to plot a map with Cartopy and the resulting figure should have square dimensions. In my (simplistic) understanding, this should be easy using the plate carrée projection, since longitude and latitude are directly used as planar coordinates. This means I expect a square map if the extent covered by latitude and longitude are the same.
However, while the following code works if the extent starts at the equator (e.g. [-120, -60, 0, 60]
), it fails for an extent apart from the equator. How does the extent have to be computed that the resulting map is a square? (I found this post, but it did not really help since the coordinate transformation only returned the given coordinates).
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=[5, 5], subplot_kw={'projection': ccrs.PlateCarree()})
fig.subplots_adjust(left=0.0, bottom=0.0, right=1.0, top=1.0)
ax.set_extent([-120, -60, 15, 75])
ax.stock_img()
fig.savefig('Test.pdf')
The following image shows the output, which unfortunately contains white borders at the vertical edges: