i'm new to cartopy and still learning basic features.
I tried to plot a specific region however, cartopy extended this region and produced a map going up to approximately 85oN when I requested 80oN. Is there a way I can ensure I only get the region I am interested in?
plt.figure(figsize=(5.12985642927, 3))
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=-35))
ax.set_extent([-100, 30, 0, 80])
ax.coastlines(resolution='110m')
gl = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=True,
linewidth=2, color='gray', alpha=0.5, linestyle='--')
You should make sure to tell the set_extent
method what coordinate system you are specifying the extents in, in this case:
ax.set_extent([-100, 30, 0, 80], crs=ccrs.PlateCarree())
This method is preferred in cartopy because it avoids having to use the set_xlim
/set_ylim
which always operate in projection coordinates, which can be the cause of much confusion when working with projections other than PlateCarree()
. Using set_extent
with an explicit crs
will always do what you expect regardless of the projection of your plot.