I have some points plotted on a NorthPolarStero map in Cartopy using the following code
JavaScript
x
16
16
1
fig, ax = plt.subplots(1,1,figsize=(8,8), subplot_kw={'projection': ccrs.NorthPolarStereo()})
2
3
ax.scatter([x[0] for x in max_coords[:-1]],
4
[x[1] for x in max_coords[:-1]],
5
color='k',
6
s=50,
7
marker='x',transform=ccrs.PlateCarree(),zorder=5,
8
label='BSH Center 1980-2020')
9
10
ax.set_extent([-180, 180, 90, 66], ccrs.PlateCarree())
11
12
ax.add_feature(cartopy.feature.LAND, edgecolor='black',zorder=1)
13
14
ax.legend(fontsize='x-large')
15
16
But I would actually like to plot just the top half of this image, like this:
If I change the “`ax.set_extent“ line to either:
[90, -90, 90, 66]
or
[-90, 90, 90, 66]
It just gives me the bottom half of the plot, like this:
Does anybody know how to get the top half? I have also tried setting the central_longitude
keyword of the NorthPolarStereo line to +/- 180, but it just shows the wrong half upside down.
Advertisement
Answer
To set extents for plotting the required area, you should use the coordinates of the projection in use ccrs.NorthPolarStereo()
. The relevant code you need is: –
JavaScript
1
2
1
ax.set_extent([-2.633e+06, 2.696e+06, -6e+04, 2.9e+06], crs=ccrs.NorthPolarStereo())
2
and you should get the plot similar to this: