importmatplotlib.tickerasmtickerfromcartopy.mpl.gridlinerimportLONGITUDE_FORMATTER,LATITUDE_FORMATTER# Add latitude/longitude gridlines.
# The first line sets up basic gridline parameters - grey dotted lines with labels.
# The next two lines suppress drawing labels on the top and right sides of the plot,
# making the plot's labels consistent with typical map conventions.
# The next two lines specify how frequently to draw gridlines - here, every
# 5 deg lat/lon. It may be best to comment these two lines out the first
# time you run the code to see the plot's overall extent, then determine
# how frequently you wish to draw the gridlines in each direction.
# The next two lines control aspects of labeling the gridlines, here their
# font size and text color.
# Lastly, the final two lines format the gridline numbers in deg N/S/E/W format.
# More information: https://scitools.org.uk/cartopy/docs/latest/matplotlib/gridliner.html
gridlines=ax.gridlines(color="grey",linestyle="dotted",draw_labels=True)gridlines.xlabels_top=Falsegridlines.ylabels_right=Falsegridlines.xlocator=mticker.FixedLocator(np.arange(-90.,-55.,5.))gridlines.ylocator=mticker.FixedLocator(np.arange(15.,45.,5.))gridlines.xlabel_style={'size':12,'color':'black'}gridlines.ylabel_style={'size':12,'color':'black'}gridlines.xformatter=LONGITUDE_FORMATTERgridlines.yformatter=LATITUDE_FORMATTER