geocat.viz.util.add_lat_lon_gridlines#
- geocat.viz.util.add_lat_lon_gridlines(ax, projection=None, draw_labels=True, xlocator=array([-180, -165, -150, -135, -120, -105, -90, -75, -60, -45, -30, -15, 0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165]), ylocator=array([-90, -75, -60, -45, -30, -15, 0, 15, 30, 45, 60, 75]), labelsize=12, **kwargs)#
Utility function that adds latitude and longtitude gridlines to the plot.
- Parameters:
ax (
cartopy.mpl.geoaxes.GeoAxes
) – Current axes to the current figure.projection (
cartopy.crs.CRS
) – Defines a Cartopy Coordinate Reference System. If not given, defaults to ccrs.PlateCarree()draw_labels (
bool
) – Toggle whether to draw labels, default to True.xlocator, ylocator (
numpy.ndarray
,list
) – Arrays of fixed locations of the gridlines in the x and y coordinate of the given CRS. Default to np.arange(-180, 180, 15) and np.arange(-90, 90, 15).labelsize (
float
) – Fontsizes of label fontsizes of x and y coordinates.*kwargs* control line properties and are passed through to `matplotlib.collections.Collection`.
- Returns:
gl (
cartopy.mpl.gridliner.Gridliner
) – A Cartopy GridLiner object.
Examples
See this example notebook: add_lat_lon_gridlines.
More in-depth plotting examples that utilize this function are in the GeoCAT-Examples Gallery. To see more usage cases, search the function on the website.