Figure
- class Figure[source]
Bases:
FigureThe
Figuresubclass used by ultraplot.- Parameters:
refnum (
int, optional) – The reference subplot number. Therefwidth,refheight, andrefaspectkeyword args are applied to this subplot, and the aspect ratio is conserved for this subplot in theauto_layout. The default is the first subplot created in the figure.refaspect (
floator2-tupleoffloat, optional) – The reference subplot aspect ratio. If scalar, this indicates the width divided by height. If 2-tuple, this indicates the (width, height). Ignored if bothfigwidthandfigheightor bothrefwidthandrefheightwere passed. The default value is1or the “data aspect ratio” if the latter is explicitly fixed (as withimshowplots andGeoAxesprojections; seeset_aspect()).refwidth, refheight (
unit-spec, default:rc['subplots.refwidth']=2.5) – The width, height of the reference subplot. If float, units are inches. If string, interpreted byunits. Ignored iffigwidth,figheight, orfigsizewas passed. If you specify just one,refaspectwill be respected.ref, aspect, axwidth, axheight – Aliases for
refnum,refaspect,refwidth,refheight. These may be deprecated in a future release.figwidth, figheight (
unit-spec, optional) – The figure width and height. Default behavior is to userefwidth. If float, units are inches. If string, interpreted byunits. If you specify just one,refaspectwill be respected.width, height – Aliases for
figwidth,figheight.figsize (
2-tuple, optional) – Tuple specifying the figure(width, height).sharex, sharey, share (
{0, False, 1, 'labels', 'labs', 2, 'limits', 'lims', 3, True, 4, 'all'}, default:rc['subplots.share']=True) – The axis sharing “level” for the x axis, y axis, or both axes. Options are as follows:0orFalse: No axis sharing. This also sets the defaultspanxandspanyvalues toFalse.1or'labels'or'labs': Only draw axis labels on the bottommost row or leftmost column of subplots. Tick labels still appear on every subplot.2or'limits'or'lims': As above but force the axis limits, scales, and tick locations to be identical. Tick labels still appear on every subplot.3orTrue: As above but only show the tick labels on the bottommost row and leftmost column of subplots.4or'all': As above but also share the axis limits, scales, and tick locations between subplots not in the same row or column.
spanx, spany, span (
boolor{0, 1}, default:rc['subplots.span']=True) – Whether to use “spanning” axis labels for the x axis, y axis, or both axes. Default isFalseifsharex,sharey, orshareare0orFalse. WhenTrue, a single, centered axis label is used for all axes with bottom and left edges in the same row or column. This can considerably redundancy in your figure. “Spanning” labels integrate with “shared” axes. For example, for a 3-row, 3-column figure, withsharey > 1andspany == True, your figure will have 1 y axis label instead of 9 y axis labels.alignx, aligny, align (
boolor{0, 1}, default:rc['subplots.align']=False) – Whether to “align” axis labels for the x axis, y axis, or both axes. Aligned labels always appear in the same row or column. This is ignored ifspanx,spany, orspanareTrue.left, right, top, bottom (
unit-spec, default:None) – The fixed space between the subplots and the figure edge. If float, units are em-widths. If string, interpreted byunits. IfNone, the space is determined automatically based on the tick and label settings. Ifrc['subplots.tight']isTrueortight=Truewas passed to the figure, the space is determined by the tight layout algorithm.wspace, hspace, space (
unit-spec, default:None) – The fixed space between grid columns, rows, or both. If float, units are em-widths. If string, interpreted byunits. IfNone, the space is determined automatically based on the font size and axis sharing settings. Ifrc['subplots.tight']isTrueortight=Truewas passed to the figure, the space is determined by the tight layout algorithm.tight (
bool, default::rc`subplots.tight`) – Whether automatic calls toauto_layoutshould include tight layout adjustments. If you manually specified a spacing in the call tosubplots, it will be used to override the tight layout spacing. For example, withleft=1, the left margin is set to 1 em-width, while the remaining margin widths are calculated automatically.wequal, hequal, equal (
bool, default:rc['subplots.equalspace']=False) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both.wgroup, hgroup, group (
bool, default:rc['subplots.groupspace']=True) – Whether to make the tight layout algorithm just consider spaces between adjacent subplots instead of entire columns and rows of subplots.outerpad (
unit-spec, default:rc['subplots.outerpad']=0.5) – The scalar tight layout padding around the left, right, top, bottom figure edges. If float, units are em-widths. If string, interpreted byunits.innerpad (
unit-spec, default:rc['subplots.innerpad']=1.0) – The scalar tight layout padding between columns and rows. Synonymous withpad. If float, units are em-widths. If string, interpreted byunits.panelpad (
unit-spec, default:rc['subplots.panelpad']=0.5) – The scalar tight layout padding between subplots and their panels, colorbars, and legends and between “stacks” of these objects. If float, units are em-widths. If string, interpreted byunits.journal (
str, optional) – String corresponding to an academic journal standard used to control the figure widthfigwidthand, if specified, the figure heightfigheight. See the below table. Feel free to add to this table by submitting a pull request.Key
Size description
Organization
'aaas1'1-column
American Association for the Advancement of Science (e.g. Science)
'aaas2'2-column
”
'agu1'1-column
'agu2'2-column
”
'agu3'full height 1-column
”
'agu4'full height 2-column
”
'ams1'1-column
'ams2'small 2-column
”
'ams3'medium 2-column
”
'ams4'full 2-column
”
'cop1'1-column
Copernicus Publications (e.g. The Cryosphere, Geoscientific Model Development)
'cop2'2-column
”
'nat1'1-column
'nat2'2-column
”
'pnas1'1-column
'pnas2'2-column
”
'pnas3'landscape page
”
- 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.**kwargs – Passed to
matplotlib.figure.Figure.
Attributes Summary
The single
GridSpecinstance used for all subplots in the figure.A
SubplotGridcontaining the numbered subplots in the figure.Methods Summary
add_axes(**kwargs)Add a non-subplot axes to the figure.
add_subplot(**kwargs)Add a subplot axes to the figure.
add_subplots(*args, **kwargs)Add an arbitrary grid of subplots to the figure.
auto_layout([renderer, aspect, tight, resize])Automatically adjust the figure size and subplot positions.
colorbar(**kwargs)Add a colorbar along the side of the figure.
draw(renderer)Draw the Artist (and its children) using the given renderer.
format()Modify figure-wide labels and call
formatfor the input axes.legend(**kwargs)Add a legend along the side of the figure.
save(filename, **kwargs)Save the figure.
savefig(**kwargs)Save the figure.
set(*[, agg_filter, alpha, animated, ...])Set multiple properties at once.
set_canvas(**kwargs)Set the figure canvas.
set_constrained_layout(constrained)[Deprecated] Set whether
constrained_layoutis used upon drawing.set_size_inches(**kwargs)Set the figure size.
set_tight_layout(tight)[Deprecated] Set whether and how
Figure.tight_layoutis called when drawing.subplot(*args, **kwargs)Add a subplot axes to the figure.
subplots(*args, **kwargs)Add an arbitrary grid of subplots to the figure.
subplots_adjust([left, bottom, right, top, ...])Adjust the subplot layout parameters.
tight_layout(*[, pad, h_pad, w_pad, rect])Adjust the padding between and around subplots.
Attributes Documentation
- alignx
- aligny
- ref
- spanx
- spany
- subplotgrid
A
SubplotGridcontaining the numbered subplots in the figure. The subplots are ordered by increasingnumber.
- tight
Methods Documentation
- add_axes(**kwargs)[source]
Add a non-subplot axes to the figure.
- Parameters:
rect (
4-tupleoffloat) – The (left, bottom, width, height) dimensions of the axes in figure-relative coordinates.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.
- Other Parameters:
**kwargs – Passed to the ultraplot class
ultraplot.axes.CartesianAxes,ultraplot.axes.PolarAxes,ultraplot.axes.GeoAxes, orultraplot.axes.ThreeAxes. This can include keyword arguments for projection-specificformatcommands.
- add_subplot(**kwargs)[source]
Add a subplot axes to the figure.
- Parameters:
*args (
int,tuple, orSubplotSpec, optional) – The subplot location specifier. Your options are:A single 3-digit integer argument specifying the number of rows, number of columns, and gridspec number (using row-major indexing).
Three positional arguments specifying the number of rows, number of columns, and gridspec number (int) or number range (2-tuple of int).
A
SubplotSpecinstance generated by indexing a ultraplotGridSpec.
For integer input, the implied geometry must be compatible with the implied geometry from previous calls – for example,
fig.add_subplot(331)followed byfig.add_subplot(132)is valid because the 1 row of the second input can be tiled into the 3 rows of the the first input, butfig.add_subplot(232)will raise an error because 2 rows cannot be tiled into 3 rows. ForSubplotSpecinput, theSubplotSpecmust be derived from theGridSpecused in previous calls.These restrictions arise because we allocate a single, unique
gridspecfor each figure.number (
int, optional) – The axes number used for a-b-c labeling. Seeformatfor details. By default this is incremented automatically based on the other subplots in the figure. Use e.g.number=Noneornumber=Falseto ensure the subplot has no a-b-c label. Note the number corresponding toais1, not0.autoshare (
bool, default:True) – Whether to automatically share the x and y axes with subplots spanning the same rows and columns based on the figure-widesharexandshareysettings. This has no effect ifrc['subplots.share']isFalseor ifsharex=Falseorsharey=Falsewere passed to the figure.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.
- Other Parameters:
**kwargs – Passed to the ultraplot class
ultraplot.axes.CartesianAxes,ultraplot.axes.PolarAxes,ultraplot.axes.GeoAxes, orultraplot.axes.ThreeAxes. This can include keyword arguments for projection-specificformatcommands.
- add_subplots(*args, **kwargs)[source]
Add an arbitrary grid of subplots to the figure.
- Parameters:
array (
ultraplot.gridspec.GridSpecor array-like ofint, optional) – The subplot grid specifier. If aGridSpec, one subplot is drawn for each uniqueGridSpecslot. If a 2D array of integers, one subplot is drawn for each unique integer in the array. Think of this array as a “picture” of the subplot grid – for example, the array[[1, 1], [2, 3]]creates one long subplot in the top row, two smaller subplots in the bottom row. Integers must range from 1 to the number of plots, and0indicates an empty space – for example,[[1, 1, 1], [2, 0, 3]]creates one long subplot in the top row with two subplots in the bottom row separated by a space.nrows, ncols (
int, default:1) – The number of rows and columns in the subplot grid. Ignored ifarraywas passed. Use these arguments for simple subplot grids.order (
{'C', 'F'}, default:'C') – Whether subplots are numbered in column-major ('C') or row-major ('F') order. Analogous tonumpy.arrayordering. This controls the order that subplots appear in theSubplotGridreturned by this function, and the order of subplot a-b-c labels (seeformat).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).To use different projections for different subplots, you have two options:
Pass a list of projection specifications, one for each subplot. For example,
uplt.subplots(ncols=2, proj=('cart', 'robin')).Pass a dictionary of projection specifications, where the keys are integers or tuples of integers that indicate the projection to use for the corresponding subplot number(s). If a key is not provided, the default projection
'cartesian'is used. For example,uplt.subplots(ncols=4, proj={2: 'cyl', (3, 4): 'stere'})creates a figure with a default Cartesian axes for the first subplot, a Mercator projection for the second subplot, and a Stereographic projection for the third and fourth subplots.
proj_kw, projection_kw (dict-like, optional) – Keyword arguments passed to
Basemapor cartopyProjectionclasses on instantiation. If dictionary of properties, applies globally. If list or dictionary of dictionaries, applies to specific subplots, as withproj. For example,uplt.subplots(ncols=2, proj='cyl', proj_kw=({'lon_0': 0}, {'lon_0': 180})centers the projection in the left subplot on the prime meridian and in the right subplot on the international dateline.backend (
{'cartopy', 'basemap'}, default:rc['geo.backend']='cartopy') – Whether to useBasemaporProjectionfor map projections. If string, applies to all subplots. If list or dict, applies to specific subplots, as withproj.left, right, top, bottom (
unit-spec, default:None) – The fixed space between the subplots and the figure edge. If float, units are em-widths. If string, interpreted byunits. IfNone, the space is determined automatically based on the tick and label settings. Ifrc['subplots.tight']isTrueortight=Truewas passed to the figure, the space is determined by the tight layout algorithm.wspace, hspace, space (
unit-specor sequence, default:None) – The fixed space between grid columns, rows, and both, respectively. If float, string, orNone, this value is expanded into lists of lengthncols - 1(forwspace) or lengthnrows - 1(forhspace). If a sequence, its length must match these lengths. If float, units are em-widths. If string, interpreted byunits.For elements equal to
None, the space is determined automatically based on the tick and label settings. Ifrc['subplots.tight']isTrueortight=Truewas passed to the figure, the space is determined by the tight layout algorithm. For example,subplots(ncols=3, tight=True, wspace=(2, None))fixes the space between columns 1 and 2 but lets the tight layout algorithm determine the space between columns 2 and 3.wratios, hratios (
floator sequence, optional) – Passed toGridSpec, denotes the width and height ratios for the subplot grid. Length ofwratiosmust match the number of columns, and length ofhratiosmust match the number of rows.width_ratios, height_ratios – Aliases for
wratios,hratios. Included for consistency withmatplotlib.gridspec.GridSpec.wpad, hpad, pad (
unit-specor sequence, optional) – The tight layout padding between columns, rows, and both, respectively. Unlikespace, these control the padding between subplot content (including text, ticks, etc.) rather than subplot edges. As withspace, these can be scalars or arrays optionally containingNone. For elements equal toNone, the default isinnerpad. If float, units are em-widths. If string, interpreted byunits.wequal, hequal, equal (
bool, default:rc['subplots.equalspace']=False) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both.wgroup, hgroup, group (
bool, default:rc['subplots.groupspace']=True) – Whether to make the tight layout algorithm just consider spaces between adjacent subplots instead of entire columns and rows of subplots.outerpad (
unit-spec, default:rc['subplots.outerpad']=0.5) – The scalar tight layout padding around the left, right, top, bottom figure edges. If float, units are em-widths. If string, interpreted byunits.innerpad (
unit-spec, default:rc['subplots.innerpad']=1.0) – The scalar tight layout padding between columns and rows. Synonymous withpad. If float, units are em-widths. If string, interpreted byunits.panelpad (
unit-spec, default:rc['subplots.panelpad']=0.5) – The scalar tight layout padding between subplots and their panels, colorbars, and legends and between “stacks” of these objects. If float, units are em-widths. If string, interpreted byunits.
- Other Parameters:
refnum (
int, optional) – The reference subplot number. Therefwidth,refheight, andrefaspectkeyword args are applied to this subplot, and the aspect ratio is conserved for this subplot in theauto_layout. The default is the first subplot created in the figure.refaspect (
floator2-tupleoffloat, optional) – The reference subplot aspect ratio. If scalar, this indicates the width divided by height. If 2-tuple, this indicates the (width, height). Ignored if bothfigwidthandfigheightor bothrefwidthandrefheightwere passed. The default value is1or the “data aspect ratio” if the latter is explicitly fixed (as withimshowplots andGeoAxesprojections; seeset_aspect()).refwidth, refheight (
unit-spec, default:rc['subplots.refwidth']=2.5) – The width, height of the reference subplot. If float, units are inches. If string, interpreted byunits. Ignored iffigwidth,figheight, orfigsizewas passed. If you specify just one,refaspectwill be respected.ref, aspect, axwidth, axheight – Aliases for
refnum,refaspect,refwidth,refheight. These may be deprecated in a future release.figwidth, figheight (
unit-spec, optional) – The figure width and height. Default behavior is to userefwidth. If float, units are inches. If string, interpreted byunits. If you specify just one,refaspectwill be respected.width, height – Aliases for
figwidth,figheight.figsize (
2-tuple, optional) – Tuple specifying the figure(width, height).sharex, sharey, share (
{0, False, 1, 'labels', 'labs', 2, 'limits', 'lims', 3, True, 4, 'all'}, default:rc['subplots.share']=True) – The axis sharing “level” for the x axis, y axis, or both axes. Options are as follows:0orFalse: No axis sharing. This also sets the defaultspanxandspanyvalues toFalse.1or'labels'or'labs': Only draw axis labels on the bottommost row or leftmost column of subplots. Tick labels still appear on every subplot.2or'limits'or'lims': As above but force the axis limits, scales, and tick locations to be identical. Tick labels still appear on every subplot.3orTrue: As above but only show the tick labels on the bottommost row and leftmost column of subplots.4or'all': As above but also share the axis limits, scales, and tick locations between subplots not in the same row or column.
spanx, spany, span (
boolor{0, 1}, default:rc['subplots.span']=True) – Whether to use “spanning” axis labels for the x axis, y axis, or both axes. Default isFalseifsharex,sharey, orshareare0orFalse. WhenTrue, a single, centered axis label is used for all axes with bottom and left edges in the same row or column. This can considerably redundancy in your figure. “Spanning” labels integrate with “shared” axes. For example, for a 3-row, 3-column figure, withsharey > 1andspany == True, your figure will have 1 y axis label instead of 9 y axis labels.alignx, aligny, align (
boolor{0, 1}, default:rc['subplots.align']=False) – Whether to “align” axis labels for the x axis, y axis, or both axes. Aligned labels always appear in the same row or column. This is ignored ifspanx,spany, orspanareTrue.left, right, top, bottom (
unit-spec, default:None) – The fixed space between the subplots and the figure edge. If float, units are em-widths. If string, interpreted byunits. IfNone, the space is determined automatically based on the tick and label settings. Ifrc['subplots.tight']isTrueortight=Truewas passed to the figure, the space is determined by the tight layout algorithm.wspace, hspace, space (
unit-spec, default:None) – The fixed space between grid columns, rows, or both. If float, units are em-widths. If string, interpreted byunits. IfNone, the space is determined automatically based on the font size and axis sharing settings. Ifrc['subplots.tight']isTrueortight=Truewas passed to the figure, the space is determined by the tight layout algorithm.tight (
bool, default::rc`subplots.tight`) – Whether automatic calls toauto_layoutshould include tight layout adjustments. If you manually specified a spacing in the call tosubplots, it will be used to override the tight layout spacing. For example, withleft=1, the left margin is set to 1 em-width, while the remaining margin widths are calculated automatically.wequal, hequal, equal (
bool, default:rc['subplots.equalspace']=False) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both.wgroup, hgroup, group (
bool, default:rc['subplots.groupspace']=True) – Whether to make the tight layout algorithm just consider spaces between adjacent subplots instead of entire columns and rows of subplots.outerpad (
unit-spec, default:rc['subplots.outerpad']=0.5) – The scalar tight layout padding around the left, right, top, bottom figure edges. If float, units are em-widths. If string, interpreted byunits.innerpad (
unit-spec, default:rc['subplots.innerpad']=1.0) – The scalar tight layout padding between columns and rows. Synonymous withpad. If float, units are em-widths. If string, interpreted byunits.panelpad (
unit-spec, default:rc['subplots.panelpad']=0.5) – The scalar tight layout padding between subplots and their panels, colorbars, and legends and between “stacks” of these objects. If float, units are em-widths. If string, interpreted byunits.journal (
str, optional) – String corresponding to an academic journal standard used to control the figure widthfigwidthand, if specified, the figure heightfigheight. See the below table. Feel free to add to this table by submitting a pull request.Key
Size description
Organization
'aaas1'1-column
American Association for the Advancement of Science (e.g. Science)
'aaas2'2-column
”
'agu1'1-column
'agu2'2-column
”
'agu3'full height 1-column
”
'agu4'full height 2-column
”
'ams1'1-column
'ams2'small 2-column
”
'ams3'medium 2-column
”
'ams4'full 2-column
”
'cop1'1-column
Copernicus Publications (e.g. The Cryosphere, Geoscientific Model Development)
'cop2'2-column
”
'nat1'1-column
'nat2'2-column
”
'pnas1'1-column
'pnas2'2-column
”
'pnas3'landscape page
”
**kwargs – Passed to the ultraplot class
ultraplot.axes.CartesianAxes,ultraplot.axes.PolarAxes,ultraplot.axes.GeoAxes, orultraplot.axes.ThreeAxes. This can include keyword arguments for projection-specificformatcommands.
- Returns:
axs (
SubplotGrid) – The axes instances stored in aSubplotGrid.
- auto_layout(renderer=None, aspect=None, tight=None, resize=None)[source]
Automatically adjust the figure size and subplot positions. This is triggered automatically whenever the figure is drawn.
- Parameters:
renderer (
RendererBase, optional) – The renderer. IfNonea default renderer will be produced.aspect (
bool, optional) – Whether to update the figure size based on the reference subplot aspect ratio. By default, this isTrue. This only has an effect if the aspect ratio is fixed (e.g., due to an image plot or geographic projection).tight (
bool, optional) – Whether to update the figuer size and subplot positions according to a “tight layout”. By default, this takes on the value oftightpassed toFigure. If nothing was passed, it isrc['subplots.tight']=True.resize (
bool, optional) – IfFalse, the current figure dimensions are fixed and automatic figure resizing is disabled. By default, the figure size may change unless bothfigwidthandfigheightorfigsizewere passed tosubplots,set_size_incheswas called manually, or the figure was resized manually with an interactive backend.
- colorbar(**kwargs)[source]
Add a colorbar along the side of the figure.
- Parameters:
mappable (
mappable,colormap-spec, sequence ofcolor-spec, :py:class:``)or sequence of `~matplotlib.artist.Artist` – There are four options here:
A
ScalarMappable(e.g., an object returned bycontourforpcolormesh).A
Colormapor registered colormap name used to build aScalarMappableon-the-fly. The colorbar range and ticks depend on the argumentsvalues,vmin,vmax, andnorm. The default for aContinuousColormapisvmin=0andvmax=1(note that passingvalueswill “discretize” the colormap). The default for aDiscreteColormapisvalues=np.arange(0, cmap.N).A sequence of hex strings, color names, or RGB[A] tuples. A
DiscreteColormapwill be generated from these colors and used to build aScalarMappableon-the-fly. The colorbar range and ticks depend on the argumentsvalues,norm, andnorm_kw. The default isvalues=np.arange(0, len(mappable)).A sequence of
matplotlib.artist.Artistinstances (e.g., a list ofLine2Dinstances returned byplot). A colormap will be generated from the colors of these objects (where the color is determined byget_color, if available, orget_facecolor). The colorbar range and ticks depend on the argumentsvalues,norm, andnorm_kw. The default is to infer colorbar ticks and tick labels by callingget_labelon each artist.
values (sequence of
floatorstr, optional) – Ignored ifmappableis aScalarMappable. This maps the colormap colors to numeric values usingDiscreteNorm. If the colormap is aContinuousColormapthen its colors will be “discretized”. These These can also be strings, in which case the list indices are used for tick locations and the strings are applied as tick labels.length (
float, default:rc['colorbar.length']=1.0) – The colorbar length. Units are relative to the span of the rows and columns of subplots.shrink (
float, optional) – Alias forlength. This is included for consistency withmatplotlib.figure.Figure.colorbar.width (
unit-spec, default:rc['colorbar.width']=0.2) – The colorbar width. If float, units are inches. If string, interpreted byunits.loc (
str, optional) – The colorbar location. Valid location keys are as follows.Location
Valid keys
left
'left','l'right
'right','r'bottom
'bottom','b'top
'top','t'space (
floatorstr, default:None) – The fixed space between the colorbar and the subplot grid 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 (
floatorstr, default:rc['subplots.innerpad']=1.0orrc['subplots.panelpad']=0.5) – The tight layout padding between the colorbar and the subplot grid. Default isrc['subplots.innerpad']for the first colorbar andrc['subplots.panelpad']for subsequently “stacked” colorbars. If float, units are em-widths. If string, interpreted byunits.row, rows – Aliases for
spanfor colorbars on the left or right side.col, cols – Aliases for
spanfor colorbars on the top or bottom side.span (
intor2-tupleofint, default:None) – Integer(s) indicating the span of the colorbar across rows and columns of subplots. For example,fig.colorbar(loc='b', col=1)draws a colorbar beneath the leftmost column of subplots, andfig.colorbar(loc='b', cols=(1, 2))draws a colorbar beneath the left two columns of subplots. By default the colorbar will span every subplot row and column.align (
{'center', 'top', 't', 'bottom', 'b', 'left', 'l', 'right', 'r'}, optional) – For outer colorbars only. How to align the colorbar against the subplot edge. The values'top'and'bottom'are valid for left and right colorbars and'left'and'right'are valid for top and bottom colorbars. The default is always'center'. Has no visible effect iflengthis1.
- Other Parameters:
orientation (
{None, 'horizontal', 'vertical'}, optional) – The colorbar orientation. By default this depends on the “side” of the subplot or figure where the colorbar is drawn. Inset colorbars are always horizontal.norm (
norm-spec, optional) – Ignored ifmappableis aScalarMappable. This is the continuous normalizer used to scale theContinuousColormap(or passed toDiscreteNormifvalueswas passed). Passed to theNormconstructor function.norm_kw (dict-like, optional) – Ignored if
mappableis aScalarMappable. These are the normalizer keyword arguments. Passed toNorm.vmin, vmax (
float, optional) – Ignored ifmappableis aScalarMappable. These are the minimum and maximum colorbar values. Passed toNorm.label, title (
str, optional) – The colorbar label. Thetitlekeyword is also accepted for consistency withlegend.reverse (
bool, optional) – Whether to reverse the direction of the colorbar. This is done automatically when descending levels are used withDiscreteNorm.rotation (
float, default:0) – The tick label rotation.grid, edges, drawedges (
bool, default:rc['colorbar.grid']=False) – Whether to draw “grid” dividers between each distinct color.extend (
{'neither', 'both', 'min', 'max'}, optional) – Direction for drawing colorbar “extensions” (i.e. color keys for out-of-bounds data on the end of the colorbar). Default behavior is to use the value ofextendpassed to the plotting command or use'neither'if the value is unknown.extendfrac (
float, optional) – The length of the colorbar “extensions” relative to the length of the colorbar. This is a native matplotlibcolorbarkeyword.extendsize (
unit-spec, default:rc['colorbar.extend']=1.3orrc['colorbar.insetextend']=0.9) – The length of the colorbar “extensions” in physical units. Default isrc['colorbar.extend']for outer colorbars andrc['colorbar.insetextend']for inset colorbars. If float, units are em-widths. If string, interpreted byunits.extendrect (
bool, default:False) – Whether to draw colorbar “extensions” as rectangles. IfFalsethen the extensions are drawn as triangles.locator, ticks (
locator-spec, optional) – Used to determine the colorbar tick positions. Passed to theLocatorconstructor function. By defaultAutoLocatoris used for continuous color levels andDiscreteLocatoris used for discrete color levels.locator_kw (dict-like, optional) – Keyword arguments passed to
matplotlib.ticker.Locatorclass.minorlocator, minorticks – As with
locator,ticksbut for the minor ticks. By defaultAutoMinorLocatoris used for continuous color levels andDiscreteLocatoris used for discrete color levels.minorlocator_kw – As with
locator_kw, but for the minor ticks.format, formatter, ticklabels (
formatter-spec, optional) – The tick label format. Passed to theFormatterconstructor function.formatter_kw (dict-like, optional) – Keyword arguments passed to
matplotlib.ticker.Formatterclass.frame, frameon (
bool, default:rc['colorbar.frameon']=True) – For inset colorbars only. Indicates whether to draw a “frame”, just likelegend.tickminor (
bool, optional) – Whether to add minor ticks usingminorticks_on.tickloc, ticklocation (
{'bottom', 'top', 'left', 'right'}, optional) – Where to draw tick marks on the colorbar. Default is toward the outside of the subplot for outer colorbars and'bottom'for inset colorbars.tickdir, tickdirection (
{'out', 'in', 'inout'}, default:rc['tick.dir']='out') – Direction of major and minor colorbar ticks.ticklen (
unit-spec, default:rc['tick.len']=4.0) – Major tick lengths for the colorbar ticks.ticklenratio (
float, default:rc['tick.lenratio']=0.5) – Relative scaling ofticklenused to determine minor tick lengths.tickwidth (
unit-spec, default:linewidth) – Major tick widths for the colorbar ticks. orrc['tick.width']=0.6iflinewidthwas not passed.tickwidthratio (
float, default:rc['tick.widthratio']=0.8) – Relative scaling oftickwidthused to determine minor tick widths.**ticklabelcolor, ticklabelsize, ticklabelweight **
default:
rc['tick.labelcolor']='black',rc['tick.labelsize']='medium',rc['tick.labelweight']='normal'. – The font color, size, and weight for colorbar tick labelslabelloc, labellocation (
{'bottom', 'top', 'left', 'right'}) – The colorbar label location. Inherits fromticklocby default. Default is toward the outside of the subplot for outer colorbars and'bottom'for inset colorbars.**labelcolor, labelsize, labelweight **
default:
rc['label.color']='black',rc['label.size']='medium', andrc['label.weight']='normal'. – The font color, size, and weight for the colorbar label.a, alpha, framealpha, fc, facecolor, framecolor, ec, edgecolor, ew, edgewidth (**default* *)
rc['colorbar.framealpha']=0.8,rc['colorbar.framecolor']– For inset colorbars only. Controls the transparency and color of the background frame.lw, linewidth, c, color (optional) – Controls the line width and edge color for both the colorbar outline and the level dividers.
edgefix (
boolorfloat, default:rc.edgefix=True) – Whether to fix the common issue where white lines appear between adjacent patches in saved vector graphics (this can slow down figure rendering). See this github repo for a demonstration of the problem. IfTrue, a small default linewidth of0.3is used to cover up the white lines. If float (e.g.edgefix=0.5), this specific linewidth is used to cover up the white lines. This feature is automatically disabled when the patches have transparency.rasterize (
bool, default:rc['colorbar.rasterize']=False) – Whether to rasterize the colorbar solids. The matplotlib default wasTruebut ultraplot changes this toFalsesince rasterization can cause misalignment between the color patches and the colorbar outline.outline (
bool, None default :None) – Controls the visibility of the frame. When set to False, the spines of the colorbar are hidden. If set toNoneit uses therc['colorbar.outline']value.labelrotation (
str,float, default:None) – Controls the rotation of the colorbar label. When set to None it takes on the value ofrc["colorbar.labelrotation"]. When set to auto it produces a sensible default where the rotation is adjusted to where the colorbar is located. For example, a horizontal colorbar with a label to the left or right will match the horizontal alignment and rotate the label to 0 degrees. Users can provide a float to rotate to any arbitrary angle.
- draw(renderer)[source]
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (
Artist.get_visiblereturns False).- Parameters:
renderer (
RendererBasesubclass.)
Notes
This method is overridden in the Artist subclasses.
- format()[source]
Modify figure-wide labels and call
formatfor the input axes. By default the numbered subplots are used.- Parameters:
axs (sequence of
Axes, optional) – The axes to format. Default is the numbered subplots.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.
Important
leftlabelpad,toplabelpad,rightlabelpad, andbottomlabelpadkeywords are actually configuration settings. We explicitly document these arguments here because it is common to change them for specific figures. But many other configuration settings can be passed toformattoo.- 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 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.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.
- legend(**kwargs)[source]
Add a legend along the side of the figure.
- Parameters:
handles (
listofartist, optional) – List of matplotlib artists, or a list of lists of artist instances (see thecenterkeyword). If not passed, artists with valid labels (applied by passinglabelorlabelsto a plotting command or callingset_label) are retrieved automatically. If the object is aContourSet,legend_elementsis used to select the central artist in the list (generally useful for single-color contour plots). Note that ultraplot’scontourandcontourfaccept a legendlabelkeyword argument.labels (
listofstr, optional) – A matching list of string labels orNoneplaceholders, or a matching list of lists (see thecenterkeyword). WhereverNoneappears in the list (or if no labels were passed at all), labels are retrieved by callingget_labelon eachArtistin the handle list. If a handle consists of a tuple group of artists, labels are inferred from the artists in the tuple (if there are multiple unique labels in the tuple group of artists, the tuple group is expanded into unique legend entries – otherwise, the tuple group elements are drawn on top of eachother). For details on matplotlib legend handlers and tuple groups, see the matplotlib `legend guide-<https (:py:class:`//matplotlib.org/stable/tutorials/intermediate/legend_guide.html>`__.`)
loc (
str, optional) – The legend location. Valid location keys are as follows.Location
Valid keys
left
'left','l'right
'right','r'bottom
'bottom','b'top
'top','t'space (
floatorstr, default:None) – The fixed space between the legend and the subplot grid 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 (
floatorstr, default:rc['subplots.innerpad']=1.0orrc['subplots.panelpad']=0.5) – The tight layout padding between the legend and the subplot grid. Default isrc['subplots.innerpad']for the first legend andrc['subplots.panelpad']for subsequently “stacked” legends. If float, units are em-widths. If string, interpreted byunits.row, rows – Aliases for
spanfor legends on the left or right side.col, cols – Aliases for
spanfor legends on the top or bottom side.span (
intor2-tupleofint, default:None) – Integer(s) indicating the span of the legend across rows and columns of subplots. For example,fig.legend(loc='b', col=1)draws a legend beneath the leftmost column of subplots, andfig.legend(loc='b', cols=(1, 2))draws a legend beneath the left two columns of subplots. By default the legend will span every subplot row and column.align (
{'center', 'top', 't', 'bottom', 'b', 'left', 'l', 'right', 'r'}, optional) – For outer legends only. How to align the legend against the subplot edge. The values'top'and'bottom'are valid for left and right legends and'left'and'right'are valid for top and bottom legends. The default is always'center'.width (
unit-spec, optional) – The space allocated for the legend box. This does nothing if the tight layout algorithm is active for the figure. If float, units are inches. If string, interpreted byunits.
- Other Parameters:
frame, frameon (
bool, optional) – Toggles the legend frame. For centered-row legends, a frame independent from matplotlib’s built-in legend frame is created.ncol, ncols (
int, optional) – The number of columns.ncolsis an alias, added for consistency withsubplots.order (
{'C', 'F'}, optional) – Whether legend handles are drawn in row-major ('C') or column-major ('F') order. Analagous tonumpy.arrayordering. The matplotlib default was'F'but ultraplot changes this to'C'.center (
bool, optional) – Whether to center each legend row individually. IfTrue, we draw successive single-row legends “stacked” on top of each other. IfNone, we infer this setting fromhandles. By default,centeris set toTrueifhandlesis a list of lists (each sublist is used as a row in the legend).alphabetize (
bool, default:False) – Whether to alphabetize the legend entries according to the legend labels.title, label (
str, optional) – The legend title. Thelabelkeyword is also accepted, for consistency withcolorbar.fontsize, fontweight, fontcolor (optional) – The font size, weight, and color for the legend text. Font size is interpreted by
units. The default font size isrc['legend.fontsize'].titlefontsize, titlefontweight, titlefontcolor (optional) – The font size, weight, and color for the legend title. Font size is interpreted by
units. The default size isfontsize.**borderpad, borderaxespad, handlelength, handleheight, handletextpad, **
labelspacing, columnspacing (
unit-spec, optional) – Various matplotliblegendspacing arguments. If float, units are em-widths. If string, interpreted byunits.**a, alpha, framealpha, fc, facecolor, framecolor, ec, edgecolor, ew, edgewidth **
default:
rc['legend.framealpha']=0.8,rc['legend.facecolor']='white',rc['legend.edgecolor']='black', :py:class:``:rc:`axes.linewidth` – The opacity, face color, edge color, and edge width for the legend frame.
c, color, lw, linewidth, m, marker, ls, linestyle, dashes, ms, markersize (optional) – Properties used to override the legend handles. For example, for a legend describing variations in line style ignoring variations in color, you might want to use
color='black'.handle_kw (dict-like, optional) – Additional properties used to override legend handles, e.g.
handle_kw={'edgecolor': 'black'}. Only line properties can be passed as keyword arguments.handler_map (dict-like, optional) – A dictionary mapping instances or types to a legend handler. This
handler_mapupdates the default handler map found atmatplotlib.legend.Legend.get_legend_handler_map.**kwargs – Passed to
legend.
- save(filename, **kwargs)[source]
Save the figure.
- Parameters:
path (path-like, optional) – The file path. User paths are expanded with
os.path.expanduser.**kwargs – Passed to
savefig
- savefig(**kwargs)[source]
Save the figure.
- Parameters:
path (path-like, optional) – The file path. User paths are expanded with
os.path.expanduser.**kwargs – Passed to
savefig
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, canvas=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, constrained_layout=<UNSET>, constrained_layout_pads=<UNSET>, dpi=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, figheight=<UNSET>, figwidth=<UNSET>, frameon=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, layout_engine=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, size_inches=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, tight_layout=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)
Set multiple properties at once.
Supported properties are
Property
Description
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image
float or None
bool
BboxBaseor Nonebool
Patch or (Path, Transform) or None
unknown
unknown
float
float
unknown
float
bool
str
bool
object
{‘constrained’, ‘compressed’, ‘tight’, ‘none’,
LayoutEngine, None}number
bool
list of
AbstractPathEffectNone or bool or float or callable
bool
unknown
(scale: float, length: float, randomness: float)
bool or None
unknown
str
bool
float
- set_canvas(**kwargs)[source]
Set the figure canvas. Add monkey patches for the instance-level
drawandprint_figuremethods.- Parameters:
canvas (
FigureCanvasBase) – The figure canvas.
See also
- set_constrained_layout(constrained)[source]
[Deprecated] Set whether
constrained_layoutis used upon drawing.If None,
rc['figure.constrained_layout.use']=Falsevalue will be used.When providing a dict containing the keys
w_pad,h_padthe defaultconstrained_layoutpaddings will be overridden. These pads are in inches and default to 3.0/72.0.w_padis the width padding andh_padis the height padding.Notes
Deprecated since version 3.6: Use set_layout_engine(‘constrained’) instead.
- set_size_inches(**kwargs)[source]
Set the figure size. If this is being called manually or from an interactive backend, update the default layout with this fixed size. If the figure size is unchanged or this is an internal call, do not update the default layout.
- Parameters:
*args (
float) – The width and height passed as positional arguments or a 2-tuple.forward (
bool, optional) – Whether to update the canvas.internal (
bool, optional) – Whether this is an internal resize.eps (
float, optional) – The deviation from the current size in inches required to treat this as a user-triggered figure resize that fixes the layout.
- set_tight_layout(tight)[source]
[Deprecated] Set whether and how
Figure.tight_layoutis called when drawing.- Parameters:
tight (
boolor dict with keys"pad","w_pad","h_pad","rect"orNone) – If a bool, sets whether to callFigure.tight_layoutupon drawing. IfNone, userc['figure.autolayout']=Falseinstead. If a dict, pass it as kwargs toFigure.tight_layout, overriding the default paddings.
Notes
Deprecated since version 3.6: Use set_layout_engine instead.
- subplot(*args, **kwargs)[source]
Add a subplot axes to the figure.
- Parameters:
*args (
int,tuple, orSubplotSpec, optional) – The subplot location specifier. Your options are:A single 3-digit integer argument specifying the number of rows, number of columns, and gridspec number (using row-major indexing).
Three positional arguments specifying the number of rows, number of columns, and gridspec number (int) or number range (2-tuple of int).
A
SubplotSpecinstance generated by indexing a ultraplotGridSpec.
For integer input, the implied geometry must be compatible with the implied geometry from previous calls – for example,
fig.add_subplot(331)followed byfig.add_subplot(132)is valid because the 1 row of the second input can be tiled into the 3 rows of the the first input, butfig.add_subplot(232)will raise an error because 2 rows cannot be tiled into 3 rows. ForSubplotSpecinput, theSubplotSpecmust be derived from theGridSpecused in previous calls.These restrictions arise because we allocate a single, unique
gridspecfor each figure.number (
int, optional) – The axes number used for a-b-c labeling. Seeformatfor details. By default this is incremented automatically based on the other subplots in the figure. Use e.g.number=Noneornumber=Falseto ensure the subplot has no a-b-c label. Note the number corresponding toais1, not0.autoshare (
bool, default:True) – Whether to automatically share the x and y axes with subplots spanning the same rows and columns based on the figure-widesharexandshareysettings. This has no effect ifrc['subplots.share']isFalseor ifsharex=Falseorsharey=Falsewere passed to the figure.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.
- Other Parameters:
**kwargs – Passed to the ultraplot class
ultraplot.axes.CartesianAxes,ultraplot.axes.PolarAxes,ultraplot.axes.GeoAxes, orultraplot.axes.ThreeAxes. This can include keyword arguments for projection-specificformatcommands.
- subplots(*args, **kwargs)[source]
Add an arbitrary grid of subplots to the figure.
- Parameters:
array (
ultraplot.gridspec.GridSpecor array-like ofint, optional) – The subplot grid specifier. If aGridSpec, one subplot is drawn for each uniqueGridSpecslot. If a 2D array of integers, one subplot is drawn for each unique integer in the array. Think of this array as a “picture” of the subplot grid – for example, the array[[1, 1], [2, 3]]creates one long subplot in the top row, two smaller subplots in the bottom row. Integers must range from 1 to the number of plots, and0indicates an empty space – for example,[[1, 1, 1], [2, 0, 3]]creates one long subplot in the top row with two subplots in the bottom row separated by a space.nrows, ncols (
int, default:1) – The number of rows and columns in the subplot grid. Ignored ifarraywas passed. Use these arguments for simple subplot grids.order (
{'C', 'F'}, default:'C') – Whether subplots are numbered in column-major ('C') or row-major ('F') order. Analogous tonumpy.arrayordering. This controls the order that subplots appear in theSubplotGridreturned by this function, and the order of subplot a-b-c labels (seeformat).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).To use different projections for different subplots, you have two options:
Pass a list of projection specifications, one for each subplot. For example,
uplt.subplots(ncols=2, proj=('cart', 'robin')).Pass a dictionary of projection specifications, where the keys are integers or tuples of integers that indicate the projection to use for the corresponding subplot number(s). If a key is not provided, the default projection
'cartesian'is used. For example,uplt.subplots(ncols=4, proj={2: 'cyl', (3, 4): 'stere'})creates a figure with a default Cartesian axes for the first subplot, a Mercator projection for the second subplot, and a Stereographic projection for the third and fourth subplots.
proj_kw, projection_kw (dict-like, optional) – Keyword arguments passed to
Basemapor cartopyProjectionclasses on instantiation. If dictionary of properties, applies globally. If list or dictionary of dictionaries, applies to specific subplots, as withproj. For example,uplt.subplots(ncols=2, proj='cyl', proj_kw=({'lon_0': 0}, {'lon_0': 180})centers the projection in the left subplot on the prime meridian and in the right subplot on the international dateline.backend (
{'cartopy', 'basemap'}, default:rc['geo.backend']='cartopy') – Whether to useBasemaporProjectionfor map projections. If string, applies to all subplots. If list or dict, applies to specific subplots, as withproj.left, right, top, bottom (
unit-spec, default:None) – The fixed space between the subplots and the figure edge. If float, units are em-widths. If string, interpreted byunits. IfNone, the space is determined automatically based on the tick and label settings. Ifrc['subplots.tight']isTrueortight=Truewas passed to the figure, the space is determined by the tight layout algorithm.wspace, hspace, space (
unit-specor sequence, default:None) – The fixed space between grid columns, rows, and both, respectively. If float, string, orNone, this value is expanded into lists of lengthncols - 1(forwspace) or lengthnrows - 1(forhspace). If a sequence, its length must match these lengths. If float, units are em-widths. If string, interpreted byunits.For elements equal to
None, the space is determined automatically based on the tick and label settings. Ifrc['subplots.tight']isTrueortight=Truewas passed to the figure, the space is determined by the tight layout algorithm. For example,subplots(ncols=3, tight=True, wspace=(2, None))fixes the space between columns 1 and 2 but lets the tight layout algorithm determine the space between columns 2 and 3.wratios, hratios (
floator sequence, optional) – Passed toGridSpec, denotes the width and height ratios for the subplot grid. Length ofwratiosmust match the number of columns, and length ofhratiosmust match the number of rows.width_ratios, height_ratios – Aliases for
wratios,hratios. Included for consistency withmatplotlib.gridspec.GridSpec.wpad, hpad, pad (
unit-specor sequence, optional) – The tight layout padding between columns, rows, and both, respectively. Unlikespace, these control the padding between subplot content (including text, ticks, etc.) rather than subplot edges. As withspace, these can be scalars or arrays optionally containingNone. For elements equal toNone, the default isinnerpad. If float, units are em-widths. If string, interpreted byunits.wequal, hequal, equal (
bool, default:rc['subplots.equalspace']=False) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both.wgroup, hgroup, group (
bool, default:rc['subplots.groupspace']=True) – Whether to make the tight layout algorithm just consider spaces between adjacent subplots instead of entire columns and rows of subplots.outerpad (
unit-spec, default:rc['subplots.outerpad']=0.5) – The scalar tight layout padding around the left, right, top, bottom figure edges. If float, units are em-widths. If string, interpreted byunits.innerpad (
unit-spec, default:rc['subplots.innerpad']=1.0) – The scalar tight layout padding between columns and rows. Synonymous withpad. If float, units are em-widths. If string, interpreted byunits.panelpad (
unit-spec, default:rc['subplots.panelpad']=0.5) – The scalar tight layout padding between subplots and their panels, colorbars, and legends and between “stacks” of these objects. If float, units are em-widths. If string, interpreted byunits.
- Other Parameters:
refnum (
int, optional) – The reference subplot number. Therefwidth,refheight, andrefaspectkeyword args are applied to this subplot, and the aspect ratio is conserved for this subplot in theauto_layout. The default is the first subplot created in the figure.refaspect (
floator2-tupleoffloat, optional) – The reference subplot aspect ratio. If scalar, this indicates the width divided by height. If 2-tuple, this indicates the (width, height). Ignored if bothfigwidthandfigheightor bothrefwidthandrefheightwere passed. The default value is1or the “data aspect ratio” if the latter is explicitly fixed (as withimshowplots andGeoAxesprojections; seeset_aspect()).refwidth, refheight (
unit-spec, default:rc['subplots.refwidth']=2.5) – The width, height of the reference subplot. If float, units are inches. If string, interpreted byunits. Ignored iffigwidth,figheight, orfigsizewas passed. If you specify just one,refaspectwill be respected.ref, aspect, axwidth, axheight – Aliases for
refnum,refaspect,refwidth,refheight. These may be deprecated in a future release.figwidth, figheight (
unit-spec, optional) – The figure width and height. Default behavior is to userefwidth. If float, units are inches. If string, interpreted byunits. If you specify just one,refaspectwill be respected.width, height – Aliases for
figwidth,figheight.figsize (
2-tuple, optional) – Tuple specifying the figure(width, height).sharex, sharey, share (
{0, False, 1, 'labels', 'labs', 2, 'limits', 'lims', 3, True, 4, 'all'}, default:rc['subplots.share']=True) – The axis sharing “level” for the x axis, y axis, or both axes. Options are as follows:0orFalse: No axis sharing. This also sets the defaultspanxandspanyvalues toFalse.1or'labels'or'labs': Only draw axis labels on the bottommost row or leftmost column of subplots. Tick labels still appear on every subplot.2or'limits'or'lims': As above but force the axis limits, scales, and tick locations to be identical. Tick labels still appear on every subplot.3orTrue: As above but only show the tick labels on the bottommost row and leftmost column of subplots.4or'all': As above but also share the axis limits, scales, and tick locations between subplots not in the same row or column.
spanx, spany, span (
boolor{0, 1}, default:rc['subplots.span']=True) – Whether to use “spanning” axis labels for the x axis, y axis, or both axes. Default isFalseifsharex,sharey, orshareare0orFalse. WhenTrue, a single, centered axis label is used for all axes with bottom and left edges in the same row or column. This can considerably redundancy in your figure. “Spanning” labels integrate with “shared” axes. For example, for a 3-row, 3-column figure, withsharey > 1andspany == True, your figure will have 1 y axis label instead of 9 y axis labels.alignx, aligny, align (
boolor{0, 1}, default:rc['subplots.align']=False) – Whether to “align” axis labels for the x axis, y axis, or both axes. Aligned labels always appear in the same row or column. This is ignored ifspanx,spany, orspanareTrue.left, right, top, bottom (
unit-spec, default:None) – The fixed space between the subplots and the figure edge. If float, units are em-widths. If string, interpreted byunits. IfNone, the space is determined automatically based on the tick and label settings. Ifrc['subplots.tight']isTrueortight=Truewas passed to the figure, the space is determined by the tight layout algorithm.wspace, hspace, space (
unit-spec, default:None) – The fixed space between grid columns, rows, or both. If float, units are em-widths. If string, interpreted byunits. IfNone, the space is determined automatically based on the font size and axis sharing settings. Ifrc['subplots.tight']isTrueortight=Truewas passed to the figure, the space is determined by the tight layout algorithm.tight (
bool, default::rc`subplots.tight`) – Whether automatic calls toauto_layoutshould include tight layout adjustments. If you manually specified a spacing in the call tosubplots, it will be used to override the tight layout spacing. For example, withleft=1, the left margin is set to 1 em-width, while the remaining margin widths are calculated automatically.wequal, hequal, equal (
bool, default:rc['subplots.equalspace']=False) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both.wgroup, hgroup, group (
bool, default:rc['subplots.groupspace']=True) – Whether to make the tight layout algorithm just consider spaces between adjacent subplots instead of entire columns and rows of subplots.outerpad (
unit-spec, default:rc['subplots.outerpad']=0.5) – The scalar tight layout padding around the left, right, top, bottom figure edges. If float, units are em-widths. If string, interpreted byunits.innerpad (
unit-spec, default:rc['subplots.innerpad']=1.0) – The scalar tight layout padding between columns and rows. Synonymous withpad. If float, units are em-widths. If string, interpreted byunits.panelpad (
unit-spec, default:rc['subplots.panelpad']=0.5) – The scalar tight layout padding between subplots and their panels, colorbars, and legends and between “stacks” of these objects. If float, units are em-widths. If string, interpreted byunits.journal (
str, optional) – String corresponding to an academic journal standard used to control the figure widthfigwidthand, if specified, the figure heightfigheight. See the below table. Feel free to add to this table by submitting a pull request.Key
Size description
Organization
'aaas1'1-column
American Association for the Advancement of Science (e.g. Science)
'aaas2'2-column
”
'agu1'1-column
'agu2'2-column
”
'agu3'full height 1-column
”
'agu4'full height 2-column
”
'ams1'1-column
'ams2'small 2-column
”
'ams3'medium 2-column
”
'ams4'full 2-column
”
'cop1'1-column
Copernicus Publications (e.g. The Cryosphere, Geoscientific Model Development)
'cop2'2-column
”
'nat1'1-column
'nat2'2-column
”
'pnas1'1-column
'pnas2'2-column
”
'pnas3'landscape page
”
**kwargs – Passed to the ultraplot class
ultraplot.axes.CartesianAxes,ultraplot.axes.PolarAxes,ultraplot.axes.GeoAxes, orultraplot.axes.ThreeAxes. This can include keyword arguments for projection-specificformatcommands.
- Returns:
axs (
SubplotGrid) – The axes instances stored in aSubplotGrid.
- subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)
Adjust the subplot layout parameters.
Unset parameters are left unmodified; initial values are given by
rc['figure.subplot.[name]'].- Parameters:
left (
float, optional) – The position of the left edge of the subplots, as a fraction of the figure width.right (
float, optional) – The position of the right edge of the subplots, as a fraction of the figure width.bottom (
float, optional) – The position of the bottom edge of the subplots, as a fraction of the figure height.top (
float, optional) – The position of the top edge of the subplots, as a fraction of the figure height.wspace (
float, optional) – The width of the padding between subplots, as a fraction of the average Axes width.hspace (
float, optional) – The height of the padding between subplots, as a fraction of the average Axes height.
- tight_layout(*, pad=1.08, h_pad=None, w_pad=None, rect=None)[source]
Adjust the padding between and around subplots.
To exclude an artist on the Axes from the bounding box calculation that determines the subplot parameters (i.e. legend, or annotation), set
a.set_in_layout(False)for that artist.- Parameters:
pad (
float, default:1.08) – Padding between the figure edge and the edges of subplots, as a fraction of the font size.h_pad, w_pad (
float, default:*pad*) – Padding (height/width) between edges of adjacent subplots, as a fraction of the font size.rect (
tuple (left,bottom,right,top), default:(0,0,1,1)) – A rectangle in normalized figure coordinates into which the whole subplots area (including labels) will fit.
See also
Figure.set_layout_engine,pyplot.tight_layout