cartopy
cartopy copied to clipboard
Stereographic gridlines labels
When making stereographic plots, it would be good for it to label meridians as well as parallels by default when using ax.gridlines(draw_labels=True). However, in cartopy 0.20.1, only the 0 degree and 180 degree meridians are labelled for me. (The parallels are labelled reasonably, though.) I found some settings of arguments to gridlines that gave reasonable results, and it would be good if there were keywords to use to set these (i.e. to set it to label either meridians or parallels or both), though I realise that may be difficult - but I thought posting this in any case may help people find solutions for labelling gridlines on stereographic plots. (I haven't thoroughly tested this, though.)
Code to reproduce
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
projection = ccrs.SouthPolarStereo()
extent = [-180, 180, -90, -60]
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(1, 1, 1, projection=projection)
ax.set_extent(extent, crs=ccrs.PlateCarree())
ax.coastlines()
#Choose one of the lines below
ax.gridlines(draw_labels=True) #default behaviour, with only 0 and 180 degree meridians labelled
#ax.gridlines(draw_labels={'bottom':'x', 'left':'x'}, auto_inline=True) #labels meridians and parallels (parallels labelled inside the plot axes, as in the default case)
#ax.gridlines(draw_labels={'bottom':'x', 'left':'x'}, auto_inline=False) #labels meridians only
#ax.gridlines(draw_labels={'y':True}, auto_inline=True) #labels parallels only (again, inside the plot area)
plt.show()
(auto_inline defaults to True, so it's not necessary to explicitly set it, but I thought I would show when it is being set to True to make it clear)