0

I have some points plotted on a NorthPolarStero map in Cartopy using the following code

fig, ax = plt.subplots(1,1,figsize=(8,8),  subplot_kw={'projection': ccrs.NorthPolarStereo()})

ax.scatter([x[0] for x in max_coords[:-1]],
           [x[1] for x in max_coords[:-1]],
           color='k',
           s=50,
           marker='x',transform=ccrs.PlateCarree(),zorder=5,
           label='BSH Center 1980-2020')

ax.set_extent([-180, 180, 90, 66], ccrs.PlateCarree())

ax.add_feature(cartopy.feature.LAND, edgecolor='black',zorder=1)

ax.legend(fontsize='x-large')

enter image description here

But I would actually like to plot just the top half of this image, like this:

enter image description here

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:

enter image description here

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.

Robbie Mallett
  • 131
  • 1
  • 11

1 Answers1

1

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: –

ax.set_extent([-2.633e+06, 2.696e+06, -6e+04, 2.9e+06], crs=ccrs.NorthPolarStereo()) 

and you should get the plot similar to this:

nps_top

swatchai
  • 17,400
  • 3
  • 39
  • 58
  • Thanks for this. Do you have any advice on how I can get rid of the 60W & 60E labels at the bottom of the figure? – Robbie Mallett Mar 11 '21 at 14:36
  • Nevermind - got it with: gl = ax.gridlines(draw_labels=True) gl.xlocator = mticker.FixedLocator(np.concatenate([np.arange(-180,-89,15),np.arange(90,181,15)])) – Robbie Mallett Mar 11 '21 at 14:44
  • There is a possible workaround here https://stackoverflow.com/questions/64019387/specify-the-lat-lon-label-location-in-cartopy-remove-at-some-sides but for the top edge. Can be altered to manipulate the bottom. – swatchai Mar 11 '21 at 14:56