SubplotGrid
- class SubplotGrid(sequence=None, **kwargs)[source]
Bases:
MutableSequence,listList-like, array-like object used to store subplots returned by
subplots. 1D indexing uses the underlying list ofAxeswhile 2D indexing uses thegridspec. See__getitem__for details.- Parameters:
sequence (sequence) – A sequence of
ultraplot.axes.Axessubplots or their children.
See also
ultraplot.ui.subplots,ultraplot.figure.Figure.subplots,ultraplot.figure.Figure.add_subplotsAttributes Summary
The
ultraplot.figure.Figureuniquely associated with thisSubplotGrid.The
GridSpecuniquely associated with thisSubplotGrid.The shape of the
GridSpecassociated with the grid.Methods Summary
altx(*args, **kwargs)Add an axis locked to the same location with a distinct x axis for every axes in the grid.
alty(*args, **kwargs)Add an axis locked to the same location with a distinct y axis for every axes in the grid.
dualx(*args, **kwargs)Add an axes locked to the same location whose x axis denotes equivalent coordinates in alternate units for every axes in the grid.
dualy(*args, **kwargs)Add an axes locked to the same location whose y axis denotes equivalent coordinates in alternate units for every axes in the grid.
format(**kwargs)Call the
formatcommand for thefigureand every axes in the grid.insert(key, value)S.insert(index, value) -- insert value before index
inset(*args, **kwargs)Add an inset axes for every axes in the grid.
inset_axes(*args, **kwargs)panel(*args, **kwargs)Add a panel axes for every axes in the grid.
panel_axes(*args, **kwargs)share_labels(*[, axis])Register an explicit label-sharing group for this subset.
twinx(*args, **kwargs)Add an axis locked to the same location with a distinct y axis for every axes in the grid.
twiny(*args, **kwargs)Add an axis locked to the same location with a distinct x axis for every axes in the grid.
Attributes Documentation
- figure
The
ultraplot.figure.Figureuniquely associated with thisSubplotGrid. This is used with theSubplotGrid.formatcommand.
- gridspec
The
GridSpecuniquely associated with thisSubplotGrid. This is used to resolve 2D indexing. See__getitem__for details.
Methods Documentation
- altx(*args, **kwargs) SubplotGrid[source]
Add an axis locked to the same location with a distinct x axis for every axes in the grid. This is an alias and arguably more intuitive name for
twiny, which generates two x axes with a shared (“twin”) y axes.- Parameters:
**kwargs – Passed to
CartesianAxes. Supports all validformatkeywords. You can optionally omit the x from keywords beginning withx– for exampleax.altx(lim=(0, 10))is equivalent toax.altx(xlim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passinglockeywords. For example,ax.altx(loc='bottom')changes the default side from top to bottom.- Returns:
SubplotGridultraplot.axes.CartesianAxesA gridofthe resulting axes.
Note
This enforces the following default settings:
Places the old x axis on the bottom and the new x axis on the top.
Makes the old top spine invisible and the new bottom, left, and right spines invisible.
Adjusts the x axis tick, tick label, and axis label positions according to the visible spine positions.
Syncs the old and new y axis limits and scales, and makes the new y axis labels invisible.
- alty(*args, **kwargs) SubplotGrid[source]
Add an axis locked to the same location with a distinct y axis for every axes in the grid. This is an alias and arguably more intuitive name for
twinx, which generates two y axes with a shared (“twin”) x axes.- Parameters:
**kwargs – Passed to
CartesianAxes. Supports all validformatkeywords. You can optionally omit the y from keywords beginning withy– for exampleax.alty(lim=(0, 10))is equivalent toax.alty(ylim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passinglockeywords. For example,ax.alty(loc='left')changes the default side from right to left.- Returns:
SubplotGridultraplot.axes.CartesianAxesA gridofthe resulting axes.
Note
This enforces the following default settings:
Places the old y axis on the left and the new y axis on the right.
Makes the old right spine invisible and the new left, bottom, and top spines invisible.
Adjusts the y axis tick, tick label, and axis label positions according to the visible spine positions.
Syncs the old and new x axis limits and scales, and makes the new x axis labels invisible.
- dualx(*args, **kwargs) SubplotGrid[source]
Add an axes locked to the same location whose x axis denotes equivalent coordinates in alternate units for every axes in the grid. This is an alternative to
matplotlib.axes.Axes.secondary_xaxiswith additional convenience features.- Parameters:
funcscale (
callable(),2-tupleofcallables, orscale-spec) – The scale used to transform units from the parent axis to the secondary axis. This can be aFuncScaleitself or a function, (function, function) tuple, or an axis scale specification interpreted by theScaleconstructor function, any of which will be used to build aFuncScaleand applied to the dual axis (seeFuncScalefor details).**kwargs – Passed to
CartesianAxes. Supports all validformatkeywords. You can optionally omit the x from keywords beginning withx– for exampleax.altx(lim=(0, 10))is equivalent toax.altx(xlim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passinglockeywords. For example,ax.altx(loc='bottom')changes the default side from top to bottom.
- Returns:
SubplotGridultraplot.axes.CartesianAxesA gridofthe resulting axes.
Note
This enforces the following default settings:
Places the old x axis on the bottom and the new x axis on the top.
Makes the old top spine invisible and the new bottom, left, and right spines invisible.
Adjusts the x axis tick, tick label, and axis label positions according to the visible spine positions.
Syncs the old and new y axis limits and scales, and makes the new y axis labels invisible.
- dualy(*args, **kwargs) SubplotGrid[source]
Add an axes locked to the same location whose y axis denotes equivalent coordinates in alternate units for every axes in the grid. This is an alternative to
matplotlib.axes.Axes.secondary_yaxiswith additional convenience features.- Parameters:
funcscale (
callable(),2-tupleofcallables, orscale-spec) – The scale used to transform units from the parent axis to the secondary axis. This can be aFuncScaleitself or a function, (function, function) tuple, or an axis scale specification interpreted by theScaleconstructor function, any of which will be used to build aFuncScaleand applied to the dual axis (seeFuncScalefor details).**kwargs – Passed to
CartesianAxes. Supports all validformatkeywords. You can optionally omit the y from keywords beginning withy– for exampleax.alty(lim=(0, 10))is equivalent toax.alty(ylim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passinglockeywords. For example,ax.alty(loc='left')changes the default side from right to left.
- Returns:
SubplotGridultraplot.axes.CartesianAxesA gridofthe resulting axes.
Note
This enforces the following default settings:
Places the old y axis on the left and the new y axis on the right.
Makes the old right spine invisible and the new left, bottom, and top spines invisible.
Adjusts the y axis tick, tick label, and axis label positions according to the visible spine positions.
Syncs the old and new x axis limits and scales, and makes the new x axis labels invisible.
- format(**kwargs)[source]
Call the
formatcommand for thefigureand every axes in the grid.- 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 be selected sequentially from the list. For exampleaxs.format(abc = ["X", "Y"])for a two-panel figure, andaxes[3:5].format(abc = ["X", "Y"])for a two-panel subset of a larger figure.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'left of y axis
'outer left','ol'right of y axis
'outer right','or'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.abcpad (
floatorunit-spec, default:rc['abc.pad']) – Horizontal offset to shift the a-b-c label position. Positive values move the label right, negative values move it left. This is separate fromabctitlepad, which controls spacing between abc and title when co-located. If float, units are points. If string, interpreted byunits.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, :py:class:`optional `) – Shorthands for the below keywords. lefttitle, centertitle, righttitle, upperlefttitle, uppercentertitle, upperrighttitle : str or sequence, optionallowerlefttitle, 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(default: 1.0),rc['axes.facecolor']='white'(default: white),rc['axes.edgecolor']='black'(default: black),rc['axes.linewidth']=0.6(default: 0.6), - Additional settings applied to the background patch, and their shorthands. Their defaults values are the'axes'properties.**kwargs – Passed to the projection-specific
formatcommand for each axes. Valid only if every axes in the grid belongs to the same class.
- Other Parameters:
rowlabels, collabels, llabels, tlabels, rlabels, blabels – Aliases for
leftlabelsandtoplabels, and forleftlabels,toplabels,rightlabels, andbottomlabels, respectively.leftlabels, toplabels, rightlabels, bottomlabels (sequence of
str, optional) – Labels for the subplots lying along the left, top, right, and bottom edges of the figure. The length of each list must match the number of subplots along the corresponding edge.leftlabelpad, toplabelpad, rightlabelpad, bottomlabelpad (
floatorunit-spec, default )rc['leftlabel.pad']=5.0,rc['toplabel.pad']=5.0,rc['rightlabel.pad']=5.0,rc['bottomlabel.pad']=5.0– The padding between the labels and the axes content. If float, units are points. If string, interpreted byunits.leftlabels_kw, toplabels_kw, rightlabels_kw, bottomlabels_kw (dict-like, optional) – Additional settings used to update the labels with
text.update().figtitle – Alias for
suptitle.suptitle (
str, optional) – The figure “super” title, centered between the left edge of the leftmost subplot and the right edge of the rightmost subplot.suptitlepad (
float, default:rc['suptitle.pad']=5.0) – The padding between the super title and the axes content. If float, units are points. If string, interpreted byunits.suptitle_kw (optional) – Additional settings used to update the super title with
text.update().includepanels (
bool, default:False) – Whether to include panels when aligning figure “super titles” along the top of the subplot grid and when aligning thespanxx axis labels andspanyy axis labels along the sides of the subplot grid.aspect (
{'auto', 'equal'}orfloat, optional) – The data aspect ratio. Seeset_aspect()for details.xlabel, ylabel (
str, optional) – The x and y axis labels. Applied withset_xlabelandset_ylabel.xlabel_kw, ylabel_kw (dict-like, optional) – Additional axis label settings applied with
set_xlabelandset_ylabel. See alsolabelpad,labelcolor,labelsize, andlabelweightbelow.xlim, ylim (
2-tupleoffloatsorNone, optional) – The x and y axis data limits. Applied withset_xlim()andset_ylim().xmin, ymin (
float, optional) – The x and y minimum data limits. Useful if you do not want to set the maximum limits.xmax, ymax (
float, optional) – The x and y maximum data limits. Useful if you do not want to set the minimum limits.xreverse, yreverse (
bool, optional) – Whether to “reverse” the x and y axis direction. Makes the x and y axes ascend left-to-right and top-to-bottom, respectively.xscale, yscale (
scale-spec, optional) – The x and y axis scales. Passed to theScaleconstructor. For example,xscale='log'applies logarithmic scaling, andxscale=('cutoff', 100, 2)applies aCutoffScale.xscale_kw, yscale_kw (dict-like, optional) – The x and y axis scale settings. Passed to
Scale.xmargin, ymargin, margin (
float, default:rc.margin=0.05) – The default margin between plotted content and the x and y axis spines in axes-relative coordinates. This is useful if you don’t witch to explicitly set axis limits. Use the keywordmarginto set both at once.xbounds, ybounds (
2-tupleoffloat, optional) – The x and y axis data bounds within which to draw the spines. For example,xlim=(0, 4)combined withxbounds=(2, 4)will prevent the spines from meeting at the origin. This also appliesxspineloc='bottom'andyspineloc='left'by default if both spines are currently visible.xtickrange, ytickrange (
2-tupleoffloat, optional) – The x and y axis data ranges within which major tick marks are labelled. For example,xlim=(-5, 5)combined withxtickrange=(-1, 1)and a tick interval of 1 will only label the ticks marks at -1, 0, and 1. SeeAutoFormatterfor details.xwraprange, ywraprange (
2-tupleoffloat, optional) – The x and y axis data ranges with which major tick mark values are wrapped. For example,xwraprange=(0, 3)causes the values 0 through 9 to be formatted as 0, 1, 2, 0, 1, 2, 0, 1, 2, 0. SeeAutoFormatterfor details. This can be combined withxtickrangeandytickrangeto make “stacked” line plots.xloc, yloc (optional) – Shorthands for
xspineloc,yspineloc.xspineloc, yspineloc (
{'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right', 'both', 'neither', 'none', 'zero', 'center'}or2-tuple, optional) – The x and y spine locations. Applied withset_position. Propagates toticklocunless specified otherwise.xtickloc, ytickloc (
{'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right', 'both', 'neither', 'none'}, optional) – Which x and y axis spines should have major and minor tick marks. Inherits fromspinelocby default and propagates toticklabellocunless specified otherwise.xticklabelloc, yticklabelloc (
{'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right', 'both', 'neither', 'none'}, optional) – Which x and y axis spines should have major tick labels. Inherits fromticklocby default and propagates tolabellocandoffsetlocunless specified otherwise.xlabelloc, ylabelloc (
{'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right'}, optional) – Which x and y axis spines should have axis labels. Inherits fromticklabellocby default (ifticklabellocis a single side).xoffsetloc, yoffsetloc (
{'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right'}, optional) – Which x and y axis spines should have the axis offset indicator. Inherits fromticklabellocby default (ifticklabellocis a single side).xtickdir, ytickdir, tickdir (
{'out', 'in', 'inout'}, optional) – Direction that major and minor tick marks point for the x and y axis. Use the keywordtickdirto control both.xticklabeldir, yticklabeldir (
{'in', 'out'}, optional) – Whether to place x and y axis tick label text inside or outside the axes. Propagates toxtickdirandytickdirunless specified otherwise.xrotation, yrotation (
float, default:0) – The rotation for x and y axis tick labels. for normal axes,rc['formatter.timerotation']='vertical'for time x axes.xgrid, ygrid, grid (
bool, default:rc.grid=True) – Whether to draw major gridlines on the x and y axis. Use the keywordgridto toggle both.xgridminor, ygridminor, gridminor (
bool, default:rc.gridminor=False) – Whether to draw minor gridlines for the x and y axis. Use the keywordgridminorto toggle both.xtickminor, ytickminor, tickminor (
bool, default:rc['tick.minor']=True) – Whether to draw minor ticks on the x and y axes. Use the keywordtickminorto toggle both.xticks, yticks (optional) – Aliases for
xlocator,ylocator.xlocator, ylocator (
locator-spec, optional) – Used to determine the x and y axis tick mark positions. Passed to theLocatorconstructor. Can be float, list of float, string, ormatplotlib.ticker.Locatorinstance. Use[],'null', or'none'for no ticks.xlocator_kw, ylocator_kw (dict-like, optional) – Keyword arguments passed to the
matplotlib.ticker.Locatorclass.xminorticks, yminorticks (optional) – Aliases for
xminorlocator,yminorlocator.xminorlocator, yminorlocator (optional) – As for
xlocator,ylocator, but for the minor ticks.xminorlocator_kw, yminorlocator_kw – As for
xlocator_kw,ylocator_kw, but for the minor locator.xticklabels, yticklabels (optional) – Aliases for
xformatter,yformatter.xformatter, yformatter (
formatter-spec, optional) – Used to determine the x and y axis tick label string format. Passed to theFormatterconstructor. Can be string, list of strings, ormatplotlib.ticker.Formatterinstance. Use[],'null', or'none'for no labels.xformatter_kw, yformatter_kw (dict-like, optional) – Keyword arguments passed to the
matplotlib.ticker.Formatterclass.xcolor, ycolor, color (
color-spec, default:rc['meta.color']='black') – Color for the x and y axis spines, ticks, tick labels, and axis labels. Use the keywordcolorto set both at once.xgridcolor, ygridcolor, gridcolor (
color-spec, default:rc['grid.color']='black') – Color for the x and y axis major and minor gridlines. Use the keywordgridcolorto set both at once.xlinewidth, ylinewidth, linewidth (
color-spec, default:rc['meta.width']=0.6) – Line width for the x and y axis spines and major ticks. Propagates totickwidthunless specified otherwise. Use the keywordlinewidthto set both at once.xtickcolor, ytickcolor, tickcolor (
color-spec, default:rc['tick.color']='black') – Color for the x and y axis ticks. Defaults arexcolor,ycolor, andcolorif they were passed. Use the keywordtickcolorto set both at once.xticklen, yticklen, ticklen (
unit-spec, default:rc['tick.len']=4.0) – Major tick lengths for the x and y axis. If float, units are points. If string, interpreted byunits. Use the keywordticklento set both at once.xticklenratio, yticklenratio, ticklenratio (
float, default:rc['tick.lenratio']=0.5) – Relative scaling ofxticklenandyticklenused to determine minor tick lengths. Use the keywordticklenratioto set both at once.xtickwidth, ytickwidth, tickwidth, (
unit-spec, default:rc['tick.width']=0.6) – Major tick widths for the x ans y axis. Default islinewidthif it was passed. If float, units are points. If string, interpreted byunits. Use the keywordtickwidthto set both at once.xtickwidthratio, ytickwidthratio, tickwidthratio (
float, default:rc['tick.widthratio']=0.8) – Relative scaling ofxtickwidthandytickwidthused to determine minor tick widths. Use the keywordtickwidthratioto set both at once.xticklabelpad, yticklabelpad, ticklabelpad (
unit-spec, default:rc['tick.labelpad']=2.0) – The padding between the x and y axis ticks and tick labels. Use the keywordticklabelpadto set both at once. If float, units are points. If string, interpreted byunits.xticklabelcolor, yticklabelcolor, ticklabelcolor (
color-spec, default:rc['tick.labelcolor']='black') – Color for the x and y tick labels. Defaults arexcolor,ycolor, andcolorif they were passed. Use the keywordticklabelcolorto set both at once.xticklabelsize, yticklabelsize, ticklabelsize (
unit-specorstr, default:rc['tick.labelsize']='medium') – Font size for the x and y tick labels. If float, units are points. If string, interpreted byunits. Use the keywordticklabelsizeto set both at once.xticklabelweight, yticklabelweight, ticklabelweight (
str, default:rc['tick.labelweight']='normal') – Font weight for the x and y tick labels. Use the keywordticklabelweightto set both at once.xlabelpad, ylabelpad (
unit-spec, default:rc['label.pad']=4.0) – The padding between the x and y axis bounding box and the x and y axis labels. If float, units are points. If string, interpreted byunits.xlabelcolor, ylabelcolor, labelcolor (
color-spec, default:rc['label.color']='black') – Color for the x and y axis labels. Defaults arexcolor,ycolor, andcolorif they were passed. Use the keywordlabelcolorto set both at once.xlabelsize, ylabelsize, labelsize (
unit-specorstr, default:rc['label.size']='medium') – Font size for the x and y axis labels. If float, units are points. If string, interpreted byunits. Use the keywordlabelsizeto set both at once.xlabelweight, ylabelweight, labelweight (
str, default:rc['label.weight']='normal') – Font weight for the x and y axis labels. Use the keywordlabelweightto set both at once.fixticks (
bool, default:False) – Whether to transform the tick locators to aFixedLocator. If your axis ticks are doing weird things (for example, ticks are drawn outside of the axis spine) you can try setting this toTrue.r0 (
float, default:0) – The radial origin.theta0 (
{'N', 'NW', 'W', 'SW', 'S', 'SE', 'E', 'NE'}, optional) – The zero azimuth location.thetadir (
{1, -1, 'anticlockwise', 'counterclockwise', 'clockwise'}, optional) – The positive azimuth direction. Clockwise corresponds to-1and anticlockwise corresponds to1.thetamin, thetamax (
float, optional) – The lower and upper azimuthal bounds in degrees. Ifthetamax != thetamin + 360, this produces a sector plot.thetalim (
2-tupleoffloatorNone, optional) – Specifiesthetaminandthetamaxat once.rmin, rmax (
float, optional) – The inner and outer radial limits. Ifr0 != rmin, this produces an annular plot.rlim (
2-tupleoffloatorNone, optional) – Specifiesrminandrmaxat once.rborder (
bool, optional) – Whether to draw the polar axes border. Visibility of the “inner” radial spine and “start” and “end” azimuthal spines is controlled automatically by matplotlib.thetagrid, rgrid, grid (
bool, optional) – Whether to draw major gridlines for the azimuthal and radial axis. Use the keywordgridto toggle both.thetagridminor, rgridminor, gridminor (
bool, optional) – Whether to draw minor gridlines for the azimuthal and radial axis. Use the keywordgridminorto toggle both.thetagridcolor, rgridcolor, gridcolor (
color-spec, optional) – Color for the major and minor azimuthal and radial gridlines. Use the keywordgridcolorto set both at once.thetalocator, rlocator (
locator-spec, optional) – Used to determine the azimuthal and radial gridline positions. Passed to theLocatorconstructor. Can be float, list of float, string, ormatplotlib.ticker.Locatorinstance.thetalines, rlines – Aliases for
thetalocator,rlocator.thetalocator_kw, rlocator_kw (dict-like, optional) – The azimuthal and radial locator settings. Passed to
Locator.thetaminorlocator, rminorlocator (optional) – As for
thetalocator,rlocator, but for the minor gridlines.thetaminorticks, rminorticks (optional) – Aliases for
thetaminorlocator,rminorlocator.thetaminorlocator_kw, rminorlocator_kw – As for
thetalocator_kw,rlocator_kw, but for the minor locator.rlabelpos (
float, optional) – The azimuth at which radial coordinates are labeled.thetaformatter, rformatter (
formatter-spec, optional) – Used to determine the azimuthal and radial label format. Passed to theFormatterconstructor. Can be string, list of string, ormatplotlib.ticker.Formatterinstance. Use[],'null', or'none'for no labels.thetalabels, rlabels (optional) – Aliases for
thetaformatter,rformatter.thetaformatter_kw, rformatter_kw (dict-like, optional) – The azimuthal and radial label formatter settings. Passed to
Formatter.color (
color-spec, default:rc['meta.color']='black') – Color for the axes edge. Propagates tolabelcolorunless specified otherwise (similar toformat()).labelcolor, gridlabelcolor (
color-spec, default:colororrc['grid.labelcolor']='black') – Color for the gridline labels.labelpad, gridlabelpad (
unit-spec, default:rc['grid.labelpad']=3.0) – The padding between the axes edge and the radial and azimuthal labels. If float, units are points. If string, interpreted byunits.labelsize, gridlabelsize (
unit-specorstr, default:rc['grid.labelsize']='medium') – Font size for the gridline labels. If float, units are points. If string, interpreted byunits.labelweight, gridlabelweight (
str, default:rc['grid.labelweight']='normal') – Font weight for the gridline labels.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.lonticklen, latticklen, ticklen (
unit-spec, default:rc['tick.len']=4.0) – Major tick lengths for the longitudinal (x) and latitude (y) axis. If float, units are points. If string, interpreted byunits. Use the keywordticklento set 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 basemapdrawmeridians()anddrawparallels()labelskeyword.
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.labelrotation (
float, optional) – The rotation angle in degrees for both longitude and latitude tick labels. Uselonlabelrotationandlatlabelrotationto set them separately.lonlabelrotation (
float, optional) – The rotation angle in degrees for longitude tick labels. Works for both cartopy and basemap backends.latlabelrotation (
float, optional) – The rotation angle in degrees for latitude tick labels. Works for both cartopy and basemap backends.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 toformat()).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).rc_mode (
int, optional) – The context mode passed tocontext.rc_kw (dict-like, optional) – An alternative to passing extra keyword arguments. See below.
**kwargs – Keyword arguments that match the name of an
rcsetting are passed toultraplot.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.
- inset(*args, **kwargs) SubplotGrid[source]
Add an inset axes for every axes in the grid. This is similar to
matplotlib.axes.Axes.inset_axes.- Parameters:
bounds (
4-tupleoffloat) – The (left, bottom, width, height) coordinates for the axes.transform (
{'data', 'axes', 'figure', 'subfigure'})or `~matplotlib.transforms.Transform`, optional – The transform used to interpret the bounds. Can be a
Transforminstance or a string representing thetransData,transAxes,transFigure, ortransSubfigure, transforms. Default is to use the same projection as the current axes.proj, projection (:py:class:``)
str, `cartopy.crs.Projection`, or `~mpl_toolkits.basemap.Basemap`, optional – The map projection specification(s). If
'cart'or'cartesian'(the default), aCartesianAxesis created. If'polar', aPolarAxesis created. Otherwise, the argument is interpreted byProj, and the result is used to make aGeoAxes(in this case the argument can be acartopy.crs.Projectioninstance, aBasemapinstance, or a projection name listed in this table).proj_kw, projection_kw (dict-like, optional) – Keyword arguments passed to
Basemapor cartopyProjectionclasses on instantiation.backend (
{'cartopy', 'basemap'}, default:rc['geo.backend']='cartopy') – Whether to useBasemaporProjectionfor map projections.zorder (
float, default:4) – The zorder of the axes. Should be greater than the zorder of elements in the parent axes.zoom (
bool, default:TrueorFalse) – Whether to draw lines indicating the inset zoom usingindicate_inset_zoom. The line positions will automatically adjust when the parent or inset axes limits change. Default isTrueonly if both axes areCartesianAxes.zoom_kw (
dict, optional) – Passed toindicate_inset_zoom.
- Other Parameters:
**kwargs – Passed to
ultraplot.axes.Axes.- Returns:
ultraplot.axes.Axes– The inset axes.
See also
Axes.indicate_inset_zoom,matplotlib.axes.Axes.inset_axes,matplotlib.axes.Axes.indicate_inset,matplotlib.axes.Axes.indicate_inset_zoom
- inset_axes(*args, **kwargs) SubplotGrid[source]
- panel(*args, **kwargs) SubplotGrid[source]
Add a panel axes for every axes in the grid.
- Parameters:
side (
str, optional) – The panel location. Valid location keys are as follows.Location
Valid keys
left
'left','l'right
'right','r'bottom
'bottom','b'top
'top','t'width (
unit-spec, default:rc['subplots.panelwidth']=0.5) – The panel width. If float, units are inches. If string, interpreted byunits.space (
unit-spec, default:None) – The fixed space between the panel and the subplot edge. If float, units are em-widths. If string, interpreted byunits. When the tight layout algorithm is active for the figure,spaceis computed automatically (seepad). Otherwise,spaceis set to a suitable default.pad (
unit-spec, default:rc['subplots.panelpad']=0.5) – The tight layout padding between the panel and the subplot. If float, units are em-widths. If string, interpreted byunits.row, rows – Aliases for
spanfor panels on the left or right side (vertical panels).col, cols – Aliases for
spanfor panels on the top or bottom side (horizontal panels).span (
intor2-tupleofint, default:None) – Integer(s) indicating the span of the panel across rows and columns of subplots. For panels on the left or right side, userowsorrowto specify which rows the panel should span. For panels on the top or bottom side, usecolsorcolto specify which columns the panel should span. For example,ax.panel('b', col=1)draws a panel beneath only the leftmost column, andax.panel('b', cols=(1, 2))draws a panel beneath the left two columns. By default the panel will span all rows or columns aligned with the parent axes.share (
bool, default:True) – Whether to enable axis sharing between the x and y axes of the main subplot and the panel long axes for each panel in the “stack”. Sharing between the panel short axis and other panel short axes is determined by figure-widesharexandshareysettings.
- Other Parameters:
**kwargs – Passed to
ultraplot.axes.CartesianAxes. Supports all validformatkeywords.- Returns:
ultraplot.axes.CartesianAxes– The panel axes.
- panel_axes(*args, **kwargs) SubplotGrid[source]
Register an explicit label-sharing group for this subset.
- twinx(*args, **kwargs) SubplotGrid[source]
Add an axis locked to the same location with a distinct y axis for every axes in the grid. This builds upon
matplotlib.axes.Axes.twinx.- Parameters:
**kwargs – Passed to
CartesianAxes. Supports all validformatkeywords. You can optionally omit the y from keywords beginning withy– for exampleax.alty(lim=(0, 10))is equivalent toax.alty(ylim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passinglockeywords. For example,ax.alty(loc='left')changes the default side from right to left.- Returns:
SubplotGridultraplot.axes.CartesianAxesA gridofthe resulting axes.
Note
This enforces the following default settings:
Places the old y axis on the left and the new y axis on the right.
Makes the old right spine invisible and the new left, bottom, and top spines invisible.
Adjusts the y axis tick, tick label, and axis label positions according to the visible spine positions.
Syncs the old and new x axis limits and scales, and makes the new x axis labels invisible.
- twiny(*args, **kwargs) SubplotGrid[source]
Add an axis locked to the same location with a distinct x axis for every axes in the grid. This builds upon
matplotlib.axes.Axes.twiny.- Parameters:
**kwargs – Passed to
CartesianAxes. Supports all validformatkeywords. You can optionally omit the x from keywords beginning withx– for exampleax.altx(lim=(0, 10))is equivalent toax.altx(xlim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passinglockeywords. For example,ax.altx(loc='bottom')changes the default side from top to bottom.- Returns:
SubplotGridultraplot.axes.CartesianAxesA gridofthe resulting axes.
Note
This enforces the following default settings:
Places the old x axis on the bottom and the new x axis on the top.
Makes the old top spine invisible and the new bottom, left, and right spines invisible.
Adjusts the x axis tick, tick label, and axis label positions according to the visible spine positions.
Syncs the old and new y axis limits and scales, and makes the new y axis labels invisible.