GeoAxes¶
- class GeoAxes(*args, **kwargs)[source]¶
Bases:
PlotAxesAxes subclass for plotting in geographic projections. Uses either cartopy or basemap as a “backend”.
Note
This subclass uses longitude and latitude as the default coordinate system for all plotting commands by internally passing
transform=cartopy.crs.PlateCarree()to cartopy commands andlatlon=Trueto basemap commands. Also, when using basemap as the “backend”, plotting is still done “cartopy-style” by calling methods from the axes instance rather than theBasemapinstance.Important
This axes subclass can be used by passing
proj='proj_name'to axes-creation commands likeadd_axes,add_subplot, andsubplots, whereproj_nameis a registered PROJ projection name. You can also pass aProjectionorBasemapinstance instead of a projection name. Alternatively, you can pass any of the matplotlib-recognized axes subclass namesproj='cartopy',proj='geo', orproj='geographic'with aProjectionmap_projectionkeyword argument, or passproj='basemap'with aBasemapmap_projectionkeyword argument.- Parameters
*args – Passed to
matplotlib.axes.Axes.map_projection (
ProjectionorBasemap) – The cartopy or basemap projection instance. This is passed automatically when calling axes-creation commands likeadd_subplot.round (
bool, default:rc['geo.round']=True) – For polar cartopy axes only. Whether to bound polar projections with circles rather than squares. Note that outer gridline labels cannot be added to circle-bounded polar projections. When basemap is the backend this argument must be passed toProjinstead.extent (
{'globe', 'auto'}, default:rc['geo.extent']='globe') – For cartopy axes only. Whether to auto adjust the map bounds based on plotted content. If'globe'then non-polar projections are fixed withset_global, non-Gnomonic polar projections are bounded at the equator, and Gnomonic polar projections are bounded at 30 degrees latitude. If'auto'nothing is done.lonlim, latlim (
2-tupleoffloat, optional) – For cartopy axes only. The approximate longitude and latitude boundaries of the map, applied withset_extent. When basemap is the backend this argument must be passed toProjinstead.boundinglat (
float, optional) – For cartopy axes only. The edge latitude for the circle bounding North Pole and South Pole-centered projections. When basemap is the backend this argument must be passed toProjinstead.longrid, latgrid, grid (
bool, default:rc.grid=True) – Whether to draw longitude and latitude gridlines. Use the keywordgridto toggle both at once.longridminor, latgridminor, gridminor (
bool, default:rc.gridminor=False) – Whether to draw “minor” longitude and latitude lines. Use the keywordgridminorto toggle both at once.latmax (
float, default:80) – The maximum absolute latitude for gridlines. Longitude gridlines are cut off poleward of this value (note this feature does not work in cartopy 0.18).nsteps (
int, default:rc['grid.nsteps']=250) – For cartopy axes only. The number of interpolation steps used to draw gridlines.lonlines, latlines (optional) – Aliases for
lonlocator,latlocator.lonlocator, latlocator (
locator-spec, optional) – Used to determine the longitude and latitude gridline locations. Passed to theLocatorconstructor. Can be string, float, list of float, ormatplotlib.ticker.Locatorinstance.For basemap or cartopy < 0.18, the defaults are
'deglon'and'deglat', which correspond to theLongitudeLocatorandLatitudeLocatorlocators (adapted from cartopy). For cartopy >= 0.18, the defaults are'dmslon'and'dmslat', which uses the same locators withdms=True. This selects gridlines at nice degree-minute-second intervals when the map extent is very small.lonlines_kw, latlines_kw (optional) – Aliases for
lonlocator_kw,latlocator_kw.lonlocator_kw, latlocator_kw (dict-like, optional) – Keyword arguments passed to the
matplotlib.ticker.Locatorclass.lonminorlocator, latminorlocator, lonminorlines, latminorlines (optional) – As with
lonlocatorandlatlocatorbut for the “minor” gridlines.lonminorlines_kw, latminorlines_kw (optional) – Aliases for
lonminorlocator_kw,latminorlocator_kw.lonminorlocator_kw, latminorlocator_kw (optional) – As with
lonlocator_kw, andlatlocator_kwbut for the “minor” gridlines.lonlabels, latlabels, labels (
str,bool, or sequence,rc['grid.labels']=False) – Whether to add non-inline longitude and latitude gridline labels, and on which sides of the map. Use the keywordlabelsto set both at once. The argument must conform to one of the following options:A boolean.
Trueindicates the bottom side for longitudes and the left side for latitudes, andFalsedisables all labels.A string or sequence of strings indicating the side names, e.g.
'top'for longitudes or('left', 'right')for latitudes.A string indicating the side names with single characters, e.g.
'bt'for longitudes or'lr'for latitudes.A string matching
'neither'(no labels),'both'(equivalent to'bt'for longitudes and'lr'for latitudes), or'all'(equivalent to'lrbt', i.e. all sides).A boolean 2-tuple indicating whether to draw labels on the
(bottom, top)sides for longitudes, and the(left, right)sides for latitudes.A boolean 4-tuple indicating whether to draw labels on the
(left, right, bottom, top)sides, as with the basemapdrawmeridiansanddrawparallelslabelskeyword.
loninline, latinline, inlinelabels (
bool, default:rc['grid.inlinelabels']=False) – For cartopy axes only. Whether to add inline longitude and latitude gridline labels. Use the keywordinlinelabelsto set both at once.rotatelabels (
bool, default:rc['grid.rotatelabels']=False) – For cartopy axes only. Whether to rotate non-inline gridline labels so that they automatically follow the map boundary curvature.labelpad (
unit-spec, default:rc['grid.labelpad']=3.0) – For cartopy axes only. The padding between non-inline gridline labels and the map boundary. If float, units are points. If string, interpreted byunits.dms (
bool, default:rc['grid.dmslabels']=True) – For cartopy axes only. Whether the default locators and formatters should use “minutes” and “seconds” for gridline labels on small scales rather than decimal degrees. Setting this toFalseis equivalent toax.format(lonlocator='deglon', latlocator='deglat')andax.format(lonformatter='deglon', latformatter='deglat').lonformatter, latformatter (
formatter-spec, optional) – Formatter used to style longitude and latitude gridline labels. Passed to theFormatterconstructor. Can be string, list of string, ormatplotlib.ticker.Formatterinstance.For basemap or cartopy < 0.18, the defaults are
'deglon'and'deglat', which correspond toSimpleFormatterpresets with degree symbols and cardinal direction suffixes. For cartopy >= 0.18, the defaults are'dmslon'and'dmslat', which uses cartopy’sLongitudeFormatterandLatitudeFormatterformatters withdms=True. This formats gridlines that do not fall on whole degrees as “minutes” and “seconds” rather than decimal degrees. Usedms=Falseto disable this.lonformatter_kw, latformatter_kw (dict-like, optional) – Keyword arguments passed to the
matplotlib.ticker.Formatterclass.land, ocean, coast, rivers, lakes, borders, innerborders (
bool, optional) – Toggles various geographic features. These are actually therc.land,rc.ocean,rc.coast,rc.rivers,rc.lakes,rc.borders, andrc.innerborderssettings passed tocontext. The style can be modified using additionalrcsettings.For example, to change
rc['land.color'], useax.format(landcolor='green'), and to changerc['land.zorder'], useax.format(landzorder=4).reso (
{'lo', 'med', 'hi', 'x-hi', 'xx-hi'}, optional) – For cartopy axes only. The resolution of geographic features. When basemap is the backend this must be passed toProjinstead.color (
color-spec, default:rc['meta.color']='black') – The color for the axes edge. Propagates tolabelcolorunless specified otherwise (similar toproplot.axes.CartesianAxes.format).gridcolor (
color-spec, default:rc['grid.color']='black') – The color for the gridline labels.labelcolor (
color-spec, default:colororrc['grid.labelcolor']='black') – The color for the gridline labels (gridlabelcoloris also allowed).labelsize (
unit-specorstr, default:rc['grid.labelsize']='medium') – The font size for the gridline labels (gridlabelsizeis also allowed). If float, units are points. If string, interpreted byunits.labelweight (
str, default:rc['grid.labelweight']='normal') – The font weight for the gridline labels (gridlabelweightis also allowed).
- Other Parameters
title (
stror sequence, optional) – The axes title. Can optionally be a sequence strings, in which case the title will be selected from the sequence according tonumber.abc (
boolorstror sequence, default:rc.abc=False) – The “a-b-c” subplot label style. Must contain the characteraorA, for example'a.', or'A'. IfTruethen the default style of'a'is used. TheaorAis replaced with the alphabetic character matching thenumber. Ifnumberis greater than 26, the characters loop around to a, …, z, aa, …, zz, aaa, …, zzz, etc. Can also be a sequence of strings, in which case the “a-b-c” label will simply be selected from the sequence according tonumber.abcloc, titleloc (
str, default:rc['abc.loc']='left',rc['title.loc']='center') – Strings indicating the location for the a-b-c label and main title. The following locations are valid:Location
Valid keys
center above axes
'center','c'left above axes
'left','l'right above axes
'right','r'lower center inside axes
'lower center','lc'upper center inside axes
'upper center','uc'upper right inside axes
'upper right','ur'upper left inside axes
'upper left','ul'lower left inside axes
'lower left','ll'lower right inside axes
'lower right','lr'abcborder, titleborder (
bool, default:rc['abc.border']=Trueandrc['title.border']=True) – Whether to draw a white border around titles and a-b-c labels positioned inside the axes. This can help them stand out on top of artists plotted inside the axes.abcbbox, titlebbox (
bool, default:rc['abc.bbox']=Falseandrc['title.bbox']=False) – Whether to draw a white bbox around titles and a-b-c labels positioned inside the axes. This can help them stand out on top of artists plotted inside the axes.abc_kw, title_kw (dict-like, optional) – Additional settings used to update the a-b-c label and title with
text.update().titlepad (
float, default:rc['title.pad']=5.0) – The padding for the inner and outer titles and a-b-c labels. If float, units are points. If string, interpreted byunits.titleabove (
bool, default:rc['title.above']=True) – Whether to try to put outer titles and a-b-c labels above panels, colorbars, or legends that are above the axes.abctitlepad (
float, default:rc['abc.titlepad']=4.0) – The horizontal padding between a-b-c labels and titles in the same location. If float, units are points. If string, interpreted byunits.ltitle, ctitle, rtitle, ultitle, uctitle, urtitle, lltitle, lctitle, lrtitle (
stror sequence, optional) – Shorthands for the below keywords.lefttitle, centertitle, righttitle, upperlefttitle, uppercentertitle, upperrighttitle, lowerlefttitle, lowercentertitle, lowerrighttitle (
stror sequence, optional) – Additional titles in specific positions (seetitlefor details). This works as an alternative to theax.format(title='Title', titleloc=loc)workflow and permits adding more than one title-like label for a single axes.a, alpha, fc, facecolor, ec, edgecolor, lw, linewidth, ls, linestyle (default:
rc['axes.alpha']=None,rc['axes.facecolor']='white',rc['axes.edgecolor']='black',rc['axes.linewidth']=0.6,'-') – Additional settings applied to the background patch, and their shorthands. Their defaults values are the'axes'properties.rc_mode (
int, optional) – The context mode passed tocontext.rc_kw (dict-like, optional) – An alternative to passing extra keyword arguments. See below.
**kwargs – Remaining keyword arguments are passed to
matplotlib.axes.Axes. Keyword arguments that match the name of anrcsetting are passed toproplot.config.Configurator.contextand used to update the axes. If the setting name has “dots” you can simply omit the dots. For example,abc='A.'modifies therc.abcsetting,titleloc='left'modifies therc['title.loc']setting,gridminor=Truemodifies therc.gridminorsetting, andgridbelow=Truemodifies therc['grid.below']setting. Many of the keyword arguments documented above are internally applied by retrieving settings passed tocontext.
See also
GeoAxes.format,proplot.constructor.Proj,proplot.axes.Axes,proplot.axes.PlotAxes,proplot.figure.Figure.subplot,proplot.figure.Figure.add_subplotAttributes Summary
The cartopy
Gridlinerused for major gridlines or a 2-tuple containing the (longitude, latitude) major gridlines returned by basemap'sdrawmeridiansanddrawparallels.The cartopy
Gridlinerused for minor gridlines or a 2-tuple containing the (longitude, latitude) minor gridlines returned by basemap'sdrawmeridiansanddrawparallels.The cartopy
Projectionor basemapBasemapinstance associated with this axes.Methods Summary
format()Modify map limits, longitude and latitude gridlines, geographic features, and more.