Figure¶
- class Figure(*, refnum=None, ref=None, refaspect=None, aspect=None, refwidth=None, refheight=None, axwidth=None, axheight=None, figwidth=None, figheight=None, width=None, height=None, journal=None, sharex=None, sharey=None, share=None, spanx=None, spany=None, span=None, alignx=None, aligny=None, align=None, left=None, right=None, top=None, bottom=None, wspace=None, hspace=None, space=None, wpad=None, hpad=None, pad=None, outerpad=None, innerpad=None, panelpad=None, includepanels=None, tight=None, mathtext_fallback=None, **kwargs)[source]¶
Bases:
matplotlib.figure.FigureThe
Figuresubclass used by proplot.- 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, indicates the (width, height). Ignored if bothfigwidthandfigheightor bothrefwidthandrefheightwere passed.refwidth, refheight (
unit-spec, optional) – The width, height of the reference subplot. Default isrc['subplots.refwidth']=2.5. 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'}, optional) – The axis sharing “level” for the x axis, y axis, or both axes. Default isrc['subplots.share']=True. 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}, optional) – Whether to use “spanning” axis labels for the x axis, y axis, or both axes. Default isFalseifsharex,sharey, orshareare0orFalse,rc['subplots.span']=Trueotherwise. 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, with
sharey > 1andspany=1, your figure will have 1 ylabel instead of 9.alignx, aligny, align (
boolor{0, 1}, optional) – 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 Only has an effect whenspanx,spany, orspanareFalse. Default isrc['subplots.align']=False.left, right, top, bottom (
unit-spec, optional) – The fixed space between the subplots and the figure edge. Default isNone. 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']isTrue, the space is determined by the tight layout algorithm.wspace, hspace, space (
unit-spec, optional) – The fixed space between grid columns, rows, or both. Default isNone. 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']isTrue, the space is determined by the tight layout algorithm.tight (
bool, optional) – Whether to haveauto_layoutinclude tight layout adjustments. Default isrc['subplots.tight']=True. 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, optional) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both. Default isFalse. Ignored ifrc.tightisFalse.outerpad (
unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default isrc['subplots.outerpad']=0.5. If float, units are em-widths. If string, interpreted byunits.innerpad (
unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous withpad. Default isrc['subplots.innerpad']=1.0. If float, units are em-widths. If string, interpreted byunits.panelpad (
unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default isrc['subplots.panelpad']=0.5. If float, units are em-widths. If string, interpreted byunits.includepanels (
bool, optional) – 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. Default isFalse.mathtext_fallback (
boolorstr, optional) – Apply thisrc['mathtext.fallback']value when drawing the figure. IfTrueor string, unavailable glyphs are replaced with a glyph from a fallback font (Computer Modern by default). Otherwise, they are replaced with the “¤” dummy character. For details see this mathtext tutorial.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
”
'nat1'1-column
'nat2'2-column
”
'pnas1'1-column
'pnas2'2-column
”
'pnas3'landscape page
”
- Other Parameters
**kwargs – Passed to
matplotlib.figure.Figure.
See also
proplot.ui.figure,proplot.ui.subplots,proplot.figure.Figure.add_subplot,proplot.figure.Figure.subplots,matplotlib.figure.FigureAttributes Summary
The single
GridSpecinstance used for all subplots in the figure.A
SubplotGridcontaining the numbered subplots in the figure.Methods Summary
add_axes(rect, **kwargs)Add a non-subplot axes to the figure.
add_subplot(*args[, number])Add a subplot axes to the figure.
add_subplots([array, ncols, nrows, order, ...])Add an arbitrary grid of subplots to the figure.
auto_layout([renderer, aspect, tight, resize])Automatically adjust the figure size and subplot positions.
colorbar(mappable[, values, loc, location, ...])Draw a colorbar along the side of the figure.
execute_constrained_layout([renderer])Use
layoutboxto determine pos positions within axes.format([axs, figtitle, suptitle, ...])Format the figure labels and title and call
formatfor the input axes.Initialize the layoutbox for use in constrained_layout.
legend([handles, labels, loc, location, ...])Draw a legend along the side of the figure.
save(filename, **kwargs)Save the figure.
savefig(filename, **kwargs)Save the figure.
set_canvas(canvas)Set the figure canvas.
set_constrained_layout(constrained)Set whether
constrained_layoutis used upon drawing.set_size_inches(w[, h, forward, internal, eps])Set the figure size.
set_tight_layout(tight)Set whether and how
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, ...])Update the
SubplotParamswith kwargs (defaulting to rc when None) and update the subplot locations.tight_layout([renderer, pad, h_pad, w_pad, rect])Automatically adjust subplot parameters to give specified padding.
Attributes Documentation
- alignx¶
- aligny¶
- ref¶
- spanx¶
- spany¶
- subplotgrid¶
A
SubplotGridcontaining the numbered subplots in the figure. The subplots are ordered by increasing subplot number.
- tight¶
Methods Documentation
- add_axes(rect, **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 (
str,cartopy.crs.Projection, orBasemap, 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.basemap (
boolor dict-like, optional) – Whether to useBasemaporProjectionfor map projections. Default isrc.basemap=False.
- add_subplot(*args, number=None, **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 ProPlotGridSpec.
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. Use0orFalseto ensure the subplot has no a-b-c label. Note the number corresponding toais1, not0.autoshare (
bool, optional) – Whether to automatically share the x and y axes with subplots spanning the same rows and columns based on the figure-widesharexandshareysettings. Default isTrue. This has no effect ifrc['subplots.share']isFalseor ifsharex=Falseorsharey=Falsewere passed to the figure.proj, projection (
str,cartopy.crs.Projection, orBasemap, 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.basemap (
boolor dict-like, optional) – Whether to useBasemaporProjectionfor map projections. Default isrc.basemap=False.
- Other Parameters
**kwargs – Passed to
matplotlib.axes.Axes.
- add_subplots(array=None, *, ncols=1, nrows=1, order='C', proj=None, projection=None, proj_kw=None, projection_kw=None, basemap=None, **kwargs)[source]¶
Add an arbitrary grid of subplots to the figure.
- Parameters
array (array-like of
int, optional) – A 2D array specifying complex grid of subplots. Think of this as a “picture” of your figure. 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.ncols, nrows (
int, optional) – The number of columns, rows in the subplot grid. Ignored ifarraywas passed. Use these arguments for simpler subplot grids.order (
{'C', 'F'}, optional) – 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 (
str,cartopy.crs.Projection, orBasemap, 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,
pplt.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,pplt.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,pplt.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.basemap (
boolor dict-like, optional) – Whether to useBasemaporProjectionfor map projections. Default isrc.basemap=False. If boolean, applies to all subplots. If list or dict, applies to specific subplots, as withproj.left, right, top, bottom (
unit-spec, optional) – The fixed space between the subplots and the figure edge. Default isNone. 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']isTrue, the space is determined by the tight layout algorithm.wspace, hspace, space (
unit-specor sequence, optional) – 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. Default isNone. If float, units are em-widths. If string, interpreted byunits.For sequence elements equal to
None, the space is determined automatically based on the font size and axis settings. Ifrc['subplots.tight']isTrue, the space is determined by the tight layout algorithm. Otherwise, a sensible default value is chosen. 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 rows, and length ofhratiosmust match the number of columns.width_ratios, height_ratios – Aliases for
wratios,hratios. Included for consistency with thematplotlib.pyplot.subplotscommand.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. Default isinnerpad. If float, units are em-widths. If string, interpreted byunits.wequal, hequal, equal (
bool, optional) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both. Default isFalse. Ignored ifrc.tightisFalse.outerpad (
unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default isrc['subplots.outerpad']=0.5. If float, units are em-widths. If string, interpreted byunits.innerpad (
unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous withpad. Default isrc['subplots.innerpad']=1.0. If float, units are em-widths. If string, interpreted byunits.panelpad (
unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default isrc['subplots.panelpad']=0.5. 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, indicates the (width, height). Ignored if bothfigwidthandfigheightor bothrefwidthandrefheightwere passed.refwidth, refheight (
unit-spec, optional) – The width, height of the reference subplot. Default isrc['subplots.refwidth']=2.5. 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'}, optional) – The axis sharing “level” for the x axis, y axis, or both axes. Default isrc['subplots.share']=True. 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}, optional) – Whether to use “spanning” axis labels for the x axis, y axis, or both axes. Default isFalseifsharex,sharey, orshareare0orFalse,rc['subplots.span']=Trueotherwise. 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, with
sharey > 1andspany=1, your figure will have 1 ylabel instead of 9.alignx, aligny, align (
boolor{0, 1}, optional) – 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 Only has an effect whenspanx,spany, orspanareFalse. Default isrc['subplots.align']=False.left, right, top, bottom (
unit-spec, optional) – The fixed space between the subplots and the figure edge. Default isNone. 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']isTrue, the space is determined by the tight layout algorithm.wspace, hspace, space (
unit-spec, optional) – The fixed space between grid columns, rows, or both. Default isNone. 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']isTrue, the space is determined by the tight layout algorithm.tight (
bool, optional) – Whether to haveauto_layoutinclude tight layout adjustments. Default isrc['subplots.tight']=True. 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, optional) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both. Default isFalse. Ignored ifrc.tightisFalse.outerpad (
unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default isrc['subplots.outerpad']=0.5. If float, units are em-widths. If string, interpreted byunits.innerpad (
unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous withpad. Default isrc['subplots.innerpad']=1.0. If float, units are em-widths. If string, interpreted byunits.panelpad (
unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default isrc['subplots.panelpad']=0.5. If float, units are em-widths. If string, interpreted byunits.includepanels (
bool, optional) – 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. Default isFalse.mathtext_fallback (
boolorstr, optional) – Apply thisrc['mathtext.fallback']value when drawing the figure. IfTrueor string, unavailable glyphs are replaced with a glyph from a fallback font (Computer Modern by default). Otherwise, they are replaced with the “¤” dummy character. For details see this mathtext tutorial.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
”
'nat1'1-column
'nat2'2-column
”
'pnas1'1-column
'pnas2'2-column
”
'pnas3'landscape page
”
**kwargs – Passed to
Figure.add_subplot.
- 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(mappable, values=None, *, loc=None, location=None, row=None, col=None, rows=None, cols=None, span=None, space=None, pad=None, width=None, **kwargs)[source]¶
Draw a colorbar along the side of the figure.
- Parameters
mappable (
mappable, sequence ofartist, sequence ofcolor-spec, orcolormap-spec) – There are four options here:A mappable object. Basically, any object with a
get_cmapmethod, like the objects returned bycontourfandpcolormesh.A sequence of matplotlib artists. Any object with a
get_colormethod will do, likeLine2Dinstances. A colormap will be generated from the colors of these objects, and colorbar levels will be selected usingvalues. IfvaluesisNone, we try to infer them by converting the handle labels returned byget_labeltofloat. Otherwise, it is set tonp.linspace(0, 1, len(mappable)).A sequence of hex strings, color string names, or RGB tuples. A colormap will be generated from these colors, and colorbar levels will be selected using
values. IfvaluesisNone, it is set tonp.linspace(0, 1, len(mappable)).A
Colormapinstance. In this case, a colorbar will be drawn using this colormap and with levels determined byvalues. IfvaluesisNone, it is set tonp.linspace(0, 1, cmap.N).
values (sequence of
floatorstr, optional) – Ignored ifmappableis a mappable object. This maps each color or plot handle in themappablelist to numeric values, from which a colormap and normalizer are constructed. 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, optional) – The colorbar length. Units are relative to the span of the rows and columns of subplots. Default isrc['colorbar.length']=1.0.shrink (
float, optional) – Alias forlength. This is included for consistency withmatplotlib.figure.Figure.colorbar.width (
unit-spec, optional) – The colorbar width. Default isrc['colorbar.width']=0.2. 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, optional) – 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, this is adjusted automatically usingpad. Otherwise, a suitable default is selected.pad (
floatorstr, optional) – The tight layout padding between the colorbar and the subplot grid. Default isrc['subplots.innerpad']=1.0for the first colorbar andrc['subplots.panelpad']=0.5for 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, optional) – 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. Default is'center'. 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
extend (
{None, 'neither', 'both', 'min', 'max'}, optional) – Direction for drawing colorbar “extensions” (i.e. references to out-of-bounds data with a unique color). These are triangles by default. IfNone, we try to use theextendattribute on the mappable object. If the attribute is unavailable, we use'neither'.extendfrac (
float, optional) – The length of the colorbar “extensions” relative to the length of the colorbar. This is a native matplotlibcolorbarkeyword.extendsize (
unit-spec, optional) – The length of the colorbar “extensions” in physical units. Default isrc['colorbar.insetextend']=0.9for inset colorbars andrc['colorbar.extend']=1.3for outer colorbars. If float, units are em-widths. If string, interpreted byunits.norm (
norm-spec, optional) – Ignored ifvaluesisNone. The normalizer for convertingvaluesto colormap colors. Passed toNorm.norm_kw (dict-like, optional) – The normalizer settings. Passed to
Norm.reverse (
bool, optional) – Whether to reverse the direction of the colorbar.tickloc, ticklocation (
{'bottom', 'top', 'left', 'right'}, optional) – Where to draw tick marks on the colorbar.tickdir, tickdirection (
{'out', 'in', 'inout'}, optional) – Direction of major and minor colorbar ticks.tickminor (
bool, optional) – Whether to add minor ticks usingminorticks_on.label, title (
str, optional) – The colorbar label. Thetitlekeyword is also accepted for consistency withlegend.labelsize, labelweight, labelcolor (optional) – The font size, weight, and color for colorbar label text.
locator, ticks (
locator-spec, optional) – Used to determine the colorbar tick positions. Passed to theLocatorconstructor function.locator_kw (dict-like, optional) – The locator settings. Passed to
Locator.minorlocator, minorticks – As with
locator,ticksbut for the minor ticks.minorlocator_kw – As with
locator_kw, but for the minor ticks.maxn (
int, optional) – Used iflocatorisNone. Determines the maximum number of levels that are ticked. Default depends on the colorbar length relative to the font size. The namemaxnis meant to be reminiscent ofMaxNLocator.maxn_minor – As with
maxn, but for the minor ticks.format, formatter, ticklabels (
formatter-spec, optional) – The tick label format. Passed to theFormatterconstructor function.formatter_kw (dict-like, optional) – The formatter settings. Passed to
Formatter.rotation (
float, optional) – The tick label rotation. Default is0.ticklabelsize, ticklabelweight, ticklabelcolor (optional) – The font size, weight, and color for colorbar tick labels.
grid, edges, drawedges (
bool, optional) – Whether to draw level dividers (i.e., gridlines) between each distinct color. Default isrc['colorbar.grid']=False.frame, frameon (
bool, optional) – For inset colorbars only. Indicates whether to draw a “frame”, just likelegend. Default isrc['colorbar.frameon']=True.a, alpha, framealpha, fc, facecolor, framecolor, ec, edgecolor, ew, edgewidth (optional) – For inset colorbars only. Controls the transparency and color of the frame. Defaults are
rc['colorbar.framealpha']=0.8andrc['colorbar.framecolor'].lw, linewidth, c, color (optional) – Controls the line width and edge color for both the colorbar outline and the level dividers.
edgefix (
boolorfloat, optional) – Whether to fix the common issue where white lines appear between adjacent patches in saved vector graphics. This can slow down figure rendering. Default isrc.edgefix=True. IfTrue, a small default linewidth is used to cover up the white lines. If float, this linewidth is used.rasterize (
bool, optional) – Whether to rasterize the colorbar solids. The matplotlib default isTruebut we change this torc['colorbar.rasterize']because rasterization can cause misalignment betweenedgesand the level patches.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.**kwargs – Passed to
colorbar.
- execute_constrained_layout(renderer=None)[source]¶
Use
layoutboxto determine pos positions within axes.See also
set_constrained_layout_pads.
- format(axs=None, figtitle=None, suptitle=None, suptitle_kw=None, llabels=None, leftlabels=None, leftlabels_kw=None, rlabels=None, rightlabels=None, rightlabels_kw=None, blabels=None, bottomlabels=None, bottomlabels_kw=None, tlabels=None, toplabels=None, toplabels_kw=None, rowlabels=None, collabels=None, **kwargs)[source]¶
Format the figure labels and title and call
formatfor the input axes. By default the numbered subplots are used.- Parameters
- Other Parameters
%(axes.format)s
%(axes.rc)s
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.
- legend(handles=None, labels=None, *, loc=None, location=None, row=None, col=None, rows=None, cols=None, span=None, space=None, pad=None, width=None, **kwargs)[source]¶
Draw 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). IfNone, artists with valid labels are retrieved automatically. If the object is aContourSet, thelegend_elementsmethod is used to pair the collection or contour set label with the central artist in the list (generally giving the central colormap color if the object is controlled with a colormap).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’s legend handlers, including tuple groups, see the matplotlib legend guide.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, optional) – 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, this is adjusted automatically usingpad. Otherwise, a suitable default is selected.pad (
floatorstr, optional) – The tight layout padding between the legend and the subplot grid. Default isrc['subplots.innerpad']=1.0for the first legend andrc['subplots.panelpad']=0.5for 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, optional) – 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. Default is'center'. 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. Default is'F'.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, optional) – Whether to alphabetize the legend entries according to the legend labels. Default isFalse.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 (optional) – The opacity, face color, edge color, and edge width for the legend frame. Defaults are
rc['legend.framealpha']=0.8,rc['legend.facecolor']='white',rc['legend.edgecolor']='black'andrc['axes.linewidth']=0.6.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(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
- set_canvas(canvas)[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]¶
Set whether
constrained_layoutis used upon drawing. If None, the rcParams[‘figure.constrained_layout.use’] value 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.See /tutorials/intermediate/constrainedlayout_guide.
- set_size_inches(w, h=None, *, forward=True, internal=False, eps=None)[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]¶
Set whether and how
tight_layoutis called when drawing.- Parameters
tight (
boolor dict with keys"pad","w_pad","h_pad","rect"orNone) – If a bool, sets whether to calltight_layoutupon drawing. IfNone, use thefigure.autolayoutrcparam instead. If a dict, pass it as kwargs totight_layout, overriding the default paddings.
- 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 ProPlotGridSpec.
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. Use0orFalseto ensure the subplot has no a-b-c label. Note the number corresponding toais1, not0.autoshare (
bool, optional) – Whether to automatically share the x and y axes with subplots spanning the same rows and columns based on the figure-widesharexandshareysettings. Default isTrue. This has no effect ifrc['subplots.share']isFalseor ifsharex=Falseorsharey=Falsewere passed to the figure.proj, projection (
str,cartopy.crs.Projection, orBasemap, 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.basemap (
boolor dict-like, optional) – Whether to useBasemaporProjectionfor map projections. Default isrc.basemap=False.
- Other Parameters
**kwargs – Passed to
matplotlib.axes.Axes.
- subplots(*args, **kwargs)[source]¶
Add an arbitrary grid of subplots to the figure.
- Parameters
array (array-like of
int, optional) – A 2D array specifying complex grid of subplots. Think of this as a “picture” of your figure. 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.ncols, nrows (
int, optional) – The number of columns, rows in the subplot grid. Ignored ifarraywas passed. Use these arguments for simpler subplot grids.order (
{'C', 'F'}, optional) – 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 (
str,cartopy.crs.Projection, orBasemap, 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,
pplt.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,pplt.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,pplt.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.basemap (
boolor dict-like, optional) – Whether to useBasemaporProjectionfor map projections. Default isrc.basemap=False. If boolean, applies to all subplots. If list or dict, applies to specific subplots, as withproj.left, right, top, bottom (
unit-spec, optional) – The fixed space between the subplots and the figure edge. Default isNone. 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']isTrue, the space is determined by the tight layout algorithm.wspace, hspace, space (
unit-specor sequence, optional) – 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. Default isNone. If float, units are em-widths. If string, interpreted byunits.For sequence elements equal to
None, the space is determined automatically based on the font size and axis settings. Ifrc['subplots.tight']isTrue, the space is determined by the tight layout algorithm. Otherwise, a sensible default value is chosen. 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 rows, and length ofhratiosmust match the number of columns.width_ratios, height_ratios – Aliases for
wratios,hratios. Included for consistency with thematplotlib.pyplot.subplotscommand.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. Default isinnerpad. If float, units are em-widths. If string, interpreted byunits.wequal, hequal, equal (
bool, optional) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both. Default isFalse. Ignored ifrc.tightisFalse.outerpad (
unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default isrc['subplots.outerpad']=0.5. If float, units are em-widths. If string, interpreted byunits.innerpad (
unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous withpad. Default isrc['subplots.innerpad']=1.0. If float, units are em-widths. If string, interpreted byunits.panelpad (
unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default isrc['subplots.panelpad']=0.5. 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, indicates the (width, height). Ignored if bothfigwidthandfigheightor bothrefwidthandrefheightwere passed.refwidth, refheight (
unit-spec, optional) – The width, height of the reference subplot. Default isrc['subplots.refwidth']=2.5. 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'}, optional) – The axis sharing “level” for the x axis, y axis, or both axes. Default isrc['subplots.share']=True. 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}, optional) – Whether to use “spanning” axis labels for the x axis, y axis, or both axes. Default isFalseifsharex,sharey, orshareare0orFalse,rc['subplots.span']=Trueotherwise. 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, with
sharey > 1andspany=1, your figure will have 1 ylabel instead of 9.alignx, aligny, align (
boolor{0, 1}, optional) – 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 Only has an effect whenspanx,spany, orspanareFalse. Default isrc['subplots.align']=False.left, right, top, bottom (
unit-spec, optional) – The fixed space between the subplots and the figure edge. Default isNone. 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']isTrue, the space is determined by the tight layout algorithm.wspace, hspace, space (
unit-spec, optional) – The fixed space between grid columns, rows, or both. Default isNone. 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']isTrue, the space is determined by the tight layout algorithm.tight (
bool, optional) – Whether to haveauto_layoutinclude tight layout adjustments. Default isrc['subplots.tight']=True. 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, optional) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both. Default isFalse. Ignored ifrc.tightisFalse.outerpad (
unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default isrc['subplots.outerpad']=0.5. If float, units are em-widths. If string, interpreted byunits.innerpad (
unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous withpad. Default isrc['subplots.innerpad']=1.0. If float, units are em-widths. If string, interpreted byunits.panelpad (
unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default isrc['subplots.panelpad']=0.5. If float, units are em-widths. If string, interpreted byunits.includepanels (
bool, optional) – 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. Default isFalse.mathtext_fallback (
boolorstr, optional) – Apply thisrc['mathtext.fallback']value when drawing the figure. IfTrueor string, unavailable glyphs are replaced with a glyph from a fallback font (Computer Modern by default). Otherwise, they are replaced with the “¤” dummy character. For details see this mathtext tutorial.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
”
'nat1'1-column
'nat2'2-column
”
'pnas1'1-column
'pnas2'2-column
”
'pnas3'landscape page
”
**kwargs – Passed to
Figure.add_subplot.
- Returns
axs (
SubplotGrid) – The axes instances stored in aSubplotGrid.
- subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)[source]¶
Update the
SubplotParamswith kwargs (defaulting to rc when None) and update the subplot locations.
- tight_layout(renderer=<deprecated parameter>, pad=1.08, h_pad=None, w_pad=None, rect=None)[source]¶
Automatically adjust subplot parameters to give specified padding.
To exclude an artist on the axes from the bounding box calculation that determines the subplot parameters (i.e. legend, or annotation), then set
a.set_in_layout(False)for that artist.- Parameters
renderer (
subclassofRendererBase, optional) – Defaults to the renderer for the figure. Deprecated.pad (
float, optional) – Padding between the figure edge and the edges of subplots, as a fraction of the font size.h_pad, w_pad (
float, optional) – Padding (height/width) between edges of adjacent subplots, as a fraction of the font size. Defaults to pad.rect (
tuple (left,bottom,right,top), optional) – A rectangle (left, bottom, right, top) in the normalized figure coordinate that the whole subplots area (including labels) will fit into. Default is (0, 0, 1, 1).
See also
Figure.set_tight_layout,pyplot.tight_layout