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.Figure

The Figure subclass used by proplot.

Parameters
  • refnum (int, optional) – The reference subplot number. The refwidth, refheight, and refaspect keyword args are applied to this subplot, and the aspect ratio is conserved for this subplot in the auto_layout. The default is the first subplot created in the figure.

  • refaspect (float or 2-tuple of float, optional) – The reference subplot aspect ratio. If scalar, this indicates the width divided by height. If 2-tuple, indicates the (width, height). Ignored if both figwidth and figheight or both refwidth and refheight were passed.

  • refwidth, refheight (unit-spec, optional) – The width, height of the reference subplot. Default is rc['subplots.refwidth'] = 2.5. If float, units are inches. If string, interpreted by units. Ignored if figwidth, figheight, or figsize was passed. If you specify just one, refaspect will 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 use refwidth. If float, units are inches. If string, interpreted by units. If you specify just one, refaspect will 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 is rc['subplots.share'] = True. Options are as follows:

    • 0 or False: No axis sharing. This also sets the default spanx and spany values to False.

    • 1 or 'labels' or 'labs': Only draw axis labels on the bottommost row or leftmost column of subplots. Tick labels still appear on every subplot.

    • 2 or 'limits' or 'lims': As above but force the axis limits, scales, and tick locations to be identical. Tick labels still appear on every subplot.

    • 3 or True: As above but only show the tick labels on the bottommost row and leftmost column of subplots.

    • 4 or '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 (bool or {0, 1}, optional) – Whether to use “spanning” axis labels for the x axis, y axis, or both axes. Default is False if sharex, sharey, or share are 0 or False, rc['subplots.span'] = True otherwise. When True, 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 > 1 and spany=1, your figure will have 1 ylabel instead of 9.

  • alignx, aligny, align (bool or {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 when spanx, spany, or span are False. Default is rc['subplots.align'] = False.

  • left, right, top, bottom (unit-spec, optional) – The fixed space between the subplots and the figure edge. Default is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, 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 is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, the space is determined by the tight layout algorithm.

  • tight (bool, optional) – Whether to have auto_layout include tight layout adjustments. Default is rc['subplots.tight'] = True. If you manually specified a spacing in the call to subplots, it will be used to override the tight layout spacing. For example, with left=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 is False. Ignored if rc.tight is False.

  • outerpad (unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default is rc['subplots.outerpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • innerpad (unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous with pad. Default is rc['subplots.innerpad'] = 1.0. If float, units are em-widths. If string, interpreted by units.

  • panelpad (unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default is rc['subplots.panelpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • includepanels (bool, optional) – Whether to include panels when aligning figure “super titles” along the top of the subplot grid and when aligning the spanx x axis labels and spany y axis labels along the sides of the subplot grid. Default is False.

  • mathtext_fallback (bool or str, optional) – Apply this rc['mathtext.fallback'] value when drawing the figure. If True or 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 width figwidth and, if specified, the figure height figheight. 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

    American Geophysical Union

    'agu2'

    2-column

    'agu3'

    full height 1-column

    'agu4'

    full height 2-column

    'ams1'

    1-column

    American Meteorological Society

    'ams2'

    small 2-column

    'ams3'

    medium 2-column

    'ams4'

    full 2-column

    'nat1'

    1-column

    Nature Research

    'nat2'

    2-column

    'pnas1'

    1-column

    Proceedings of the National Academy of Sciences

    'pnas2'

    2-column

    'pnas3'

    landscape page

Other Parameters

**kwargs – Passed to matplotlib.figure.Figure.

Attributes Summary

alignx

aligny

gridspec

The single GridSpec instance used for all subplots in the figure.

ref

sharex

sharey

spanx

spany

subplotgrid

A SubplotGrid containing the numbered subplots in the figure.

tight

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 layoutbox to determine pos positions within axes.

format([axs, figtitle, suptitle, ...])

Format the figure labels and title and call format for the input axes.

init_layoutbox()

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_layout is used upon drawing.

set_size_inches(w[, h, forward, internal, eps])

Set the figure size.

set_tight_layout(tight)

Set whether and how tight_layout is 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 SubplotParams with 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
gridspec

The single GridSpec instance used for all subplots in the figure.

ref
sharex
sharey
spanx
spany
subplotgrid

A SubplotGrid containing 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
add_subplot(*args, number=None, **kwargs)[source]

Add a subplot axes to the figure.

Parameters
  • *args (int, tuple, or SubplotSpec, 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 SubplotSpec instance generated by indexing a ProPlot GridSpec.

    For integer input, the implied geometry must be compatible with the implied geometry from previous calls – for example, fig.add_subplot(331) followed by fig.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, but fig.add_subplot(232) will raise an error because 2 rows cannot be tiled into 3 rows. For SubplotSpec input, the SubplotSpec must be derived from the GridSpec used in previous calls.

    These restrictions arise because we allocate a single, unique gridspec for each figure.

  • number (int, optional) – The axes number used for a-b-c labeling. See format for details. By default this is incremented automatically based on the other subplots in the figure. Use 0 or False to ensure the subplot has no a-b-c label. Note the number corresponding to a is 1, not 0.

  • autoshare (bool, optional) – Whether to automatically share the x and y axes with subplots spanning the same rows and columns based on the figure-wide sharex and sharey settings. Default is True. This has no effect if rc['subplots.share'] is False or if sharex=False or sharey=False were passed to the figure.

  • proj, projection (str, cartopy.crs.Projection, or Basemap, optional) – The map projection specification(s). If 'cart' or 'cartesian' (the default), a CartesianAxes is created. If 'polar', a PolarAxes is created. Otherwise, the argument is interpreted by Proj, and the result is used to make a GeoAxes (in this case the argument can be a cartopy.crs.Projection instance, a Basemap instance, or a projection name listed in this table).

  • proj_kw, projection_kw (dict-like, optional) – Keyword arguments passed to Basemap or cartopy Projection classes on instantiation.

  • basemap (bool or dict-like, optional) – Whether to use Basemap or Projection for map projections. Default is rc.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, and 0 indicates 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 if array was 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 to numpy.array ordering. This controls the order that subplots appear in the SubplotGrid returned by this function, and the order of subplot a-b-c labels (see format).

  • proj, projection (str, cartopy.crs.Projection, or Basemap, optional) – The map projection specification(s). If 'cart' or 'cartesian' (the default), a CartesianAxes is created. If 'polar', a PolarAxes is created. Otherwise, the argument is interpreted by Proj, and the result is used to make a GeoAxes (in this case the argument can be a cartopy.crs.Projection instance, a Basemap instance, 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 Basemap or cartopy Projection classes on instantiation. If dictionary of properties, applies globally. If list or dictionary of dictionaries, applies to specific subplots, as with proj. 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 (bool or dict-like, optional) – Whether to use Basemap or Projection for map projections. Default is rc.basemap = False. If boolean, applies to all subplots. If list or dict, applies to specific subplots, as with proj.

  • left, right, top, bottom (unit-spec, optional) – The fixed space between the subplots and the figure edge. Default is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, the space is determined by the tight layout algorithm.

  • wspace, hspace, space (unit-spec or sequence, optional) – The fixed space between grid columns, rows, and both, respectively. If float, string, or None, this value is expanded into lists of length ncols - 1 (for wspace) or length nrows - 1 (for hspace). If a sequence, its length must match these lengths. Default is None. If float, units are em-widths. If string, interpreted by units.

    For sequence elements equal to None, the space is determined automatically based on the font size and axis settings. If rc['subplots.tight'] is True, 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 (float or sequence, optional) – Passed to GridSpec, denotes the width and height ratios for the subplot grid. Length of wratios must match the number of rows, and length of hratios must match the number of columns.

  • width_ratios, height_ratios – Aliases for wratios, hratios. Included for consistency with the matplotlib.pyplot.subplots command.

  • wpad, hpad, pad (unit-spec or sequence, optional) – The tight layout padding between columns, rows, and both, respectively. Unlike space, these control the padding between subplot content (including text, ticks, etc.) rather than subplot edges. As with space, these can be scalars or arrays optionally containing None. Default is innerpad. If float, units are em-widths. If string, interpreted by units.

  • wequal, hequal, equal (bool, optional) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both. Default is False. Ignored if rc.tight is False.

  • outerpad (unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default is rc['subplots.outerpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • innerpad (unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous with pad. Default is rc['subplots.innerpad'] = 1.0. If float, units are em-widths. If string, interpreted by units.

  • panelpad (unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default is rc['subplots.panelpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

Other Parameters
  • refnum (int, optional) – The reference subplot number. The refwidth, refheight, and refaspect keyword args are applied to this subplot, and the aspect ratio is conserved for this subplot in the auto_layout. The default is the first subplot created in the figure.

  • refaspect (float or 2-tuple of float, optional) – The reference subplot aspect ratio. If scalar, this indicates the width divided by height. If 2-tuple, indicates the (width, height). Ignored if both figwidth and figheight or both refwidth and refheight were passed.

  • refwidth, refheight (unit-spec, optional) – The width, height of the reference subplot. Default is rc['subplots.refwidth'] = 2.5. If float, units are inches. If string, interpreted by units. Ignored if figwidth, figheight, or figsize was passed. If you specify just one, refaspect will 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 use refwidth. If float, units are inches. If string, interpreted by units. If you specify just one, refaspect will 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 is rc['subplots.share'] = True. Options are as follows:

    • 0 or False: No axis sharing. This also sets the default spanx and spany values to False.

    • 1 or 'labels' or 'labs': Only draw axis labels on the bottommost row or leftmost column of subplots. Tick labels still appear on every subplot.

    • 2 or 'limits' or 'lims': As above but force the axis limits, scales, and tick locations to be identical. Tick labels still appear on every subplot.

    • 3 or True: As above but only show the tick labels on the bottommost row and leftmost column of subplots.

    • 4 or '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 (bool or {0, 1}, optional) – Whether to use “spanning” axis labels for the x axis, y axis, or both axes. Default is False if sharex, sharey, or share are 0 or False, rc['subplots.span'] = True otherwise. When True, 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 > 1 and spany=1, your figure will have 1 ylabel instead of 9.

  • alignx, aligny, align (bool or {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 when spanx, spany, or span are False. Default is rc['subplots.align'] = False.

  • left, right, top, bottom (unit-spec, optional) – The fixed space between the subplots and the figure edge. Default is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, 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 is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, the space is determined by the tight layout algorithm.

  • tight (bool, optional) – Whether to have auto_layout include tight layout adjustments. Default is rc['subplots.tight'] = True. If you manually specified a spacing in the call to subplots, it will be used to override the tight layout spacing. For example, with left=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 is False. Ignored if rc.tight is False.

  • outerpad (unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default is rc['subplots.outerpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • innerpad (unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous with pad. Default is rc['subplots.innerpad'] = 1.0. If float, units are em-widths. If string, interpreted by units.

  • panelpad (unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default is rc['subplots.panelpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • includepanels (bool, optional) – Whether to include panels when aligning figure “super titles” along the top of the subplot grid and when aligning the spanx x axis labels and spany y axis labels along the sides of the subplot grid. Default is False.

  • mathtext_fallback (bool or str, optional) – Apply this rc['mathtext.fallback'] value when drawing the figure. If True or 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 width figwidth and, if specified, the figure height figheight. 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

    American Geophysical Union

    'agu2'

    2-column

    'agu3'

    full height 1-column

    'agu4'

    full height 2-column

    'ams1'

    1-column

    American Meteorological Society

    'ams2'

    small 2-column

    'ams3'

    medium 2-column

    'ams4'

    full 2-column

    'nat1'

    1-column

    Nature Research

    'nat2'

    2-column

    'pnas1'

    1-column

    Proceedings of the National Academy of Sciences

    'pnas2'

    2-column

    'pnas3'

    landscape page

  • **kwargs – Passed to Figure.add_subplot.

Returns

axs (SubplotGrid) – The axes instances stored in a SubplotGrid.

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. If None a default renderer will be produced.

  • aspect (bool, optional) – Whether to update the figure size based on the reference subplot aspect ratio. By default, this is True. 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 of tight passed to Figure. If nothing was passed, it is rc['subplots.tight'] = True.

  • resize (bool, optional) – If False, the current figure dimensions are fixed and automatic figure resizing is disabled. By default, the figure size may change unless both figwidth and figheight or figsize were passed to subplots, set_size_inches was 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 of artist, sequence of color-spec, or colormap-spec) – There are four options here:

    1. A mappable object. Basically, any object with a get_cmap method, like the objects returned by contourf and pcolormesh.

    2. A sequence of matplotlib artists. Any object with a get_color method will do, like Line2D instances. A colormap will be generated from the colors of these objects, and colorbar levels will be selected using values. If values is None, we try to infer them by converting the handle labels returned by get_label to float. Otherwise, it is set to np.linspace(0, 1, len(mappable)).

    3. 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. If values is None, it is set to np.linspace(0, 1, len(mappable)).

    4. A Colormap instance. In this case, a colorbar will be drawn using this colormap and with levels determined by values. If values is None, it is set to np.linspace(0, 1, cmap.N).

  • values (sequence of float or str, optional) – Ignored if mappable is a mappable object. This maps each color or plot handle in the mappable list 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 is rc['colorbar.length'] = 1.0.

  • shrink (float, optional) – Alias for length. This is included for consistency with matplotlib.figure.Figure.colorbar.

  • width (unit-spec, optional) – The colorbar width. Default is rc['colorbar.width'] = 0.2. If float, units are inches. If string, interpreted by units.

  • 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 (float or str, optional) – The fixed space between the colorbar and the subplot grid edge. If float, units are em-widths. If string, interpreted by units. When the tight layout algorithm is active for the figure, this is adjusted automatically using pad. Otherwise, a suitable default is selected.

  • pad (float or str, optional) – The tight layout padding between the colorbar and the subplot grid. Default is rc['subplots.innerpad'] = 1.0 for the first colorbar and rc['subplots.panelpad'] = 0.5 for subsequently stacked colorbars. If float, units are em-widths. If string, interpreted by units.

  • row, rows – Aliases for span for colorbars on the left or right side.

  • col, cols – Aliases for span for colorbars on the top or bottom side.

  • span (int or 2-tuple of int, 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, and fig.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 if length is 1.

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. If None, we try to use the extend attribute 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 matplotlib colorbar keyword.

  • extendsize (unit-spec, optional) – The length of the colorbar “extensions” in physical units. Default is rc['colorbar.insetextend'] = 0.9 for inset colorbars and rc['colorbar.extend'] = 1.3 for outer colorbars. If float, units are em-widths. If string, interpreted by units.

  • norm (norm-spec, optional) – Ignored if values is None. The normalizer for converting values to colormap colors. Passed to Norm.

  • 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 using minorticks_on.

  • label, title (str, optional) – The colorbar label. The title keyword is also accepted for consistency with legend.

  • 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 the Locator constructor function.

  • locator_kw (dict-like, optional) – The locator settings. Passed to Locator.

  • minorlocator, minorticks – As with locator, ticks but for the minor ticks.

  • minorlocator_kw – As with locator_kw, but for the minor ticks.

  • maxn (int, optional) – Used if locator is None. Determines the maximum number of levels that are ticked. Default depends on the colorbar length relative to the font size. The name maxn is meant to be reminiscent of MaxNLocator.

  • maxn_minor – As with maxn, but for the minor ticks.

  • format, formatter, ticklabels (formatter-spec, optional) – The tick label format. Passed to the Formatter constructor function.

  • formatter_kw (dict-like, optional) – The formatter settings. Passed to Formatter.

  • rotation (float, optional) – The tick label rotation. Default is 0.

  • 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 is rc['colorbar.grid'] = False.

  • frame, frameon (bool, optional) – For inset colorbars only. Indicates whether to draw a “frame”, just like legend. Default is rc['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.8 and rc['colorbar.framecolor'].

  • lw, linewidth, c, color (optional) – Controls the line width and edge color for both the colorbar outline and the level dividers.

  • edgefix (bool or float, 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 is rc.edgefix = True. If True, 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 is True but we change this to rc['colorbar.rasterize'] because rasterization can cause misalignment between edges and 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 layoutbox to 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 format for the input axes. By default the numbered subplots are used.

Parameters
  • axs (sequence of Axes, optional) – The axes to format.

  • %(figure.format)s

  • **kwargs – Passed to the projection-specific format command for each axes.

Other Parameters
  • %(axes.format)s

  • %(axes.rc)s

Important

leftlabelpad, toplabelpad, rightlabelpad, and bottomlabelpad keywords 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 to format too.

init_layoutbox()[source]

Initialize the layoutbox for use in constrained_layout.

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 (list of artist, optional) – List of matplotlib artists, or a list of lists of artist instances (see the center keyword). If None, artists with valid labels are retrieved automatically. If the object is a ContourSet, the legend_elements method 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 (list of str, optional) – A matching list of string labels or None placeholders, or a matching list of lists (see the center keyword). Wherever None appears in the list (or if no labels were passed at all), labels are retrieved by calling get_label on each Artist in 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 (float or str, optional) – The fixed space between the legend and the subplot grid edge. If float, units are em-widths. If string, interpreted by units. When the tight layout algorithm is active for the figure, this is adjusted automatically using pad. Otherwise, a suitable default is selected.

  • pad (float or str, optional) – The tight layout padding between the legend and the subplot grid. Default is rc['subplots.innerpad'] = 1.0 for the first legend and rc['subplots.panelpad'] = 0.5 for subsequently stacked legends. If float, units are em-widths. If string, interpreted by units.

  • row, rows – Aliases for span for legends on the left or right side.

  • col, cols – Aliases for span for legends on the top or bottom side.

  • span (int or 2-tuple of int, 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, and fig.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 by units.

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. ncols is an alias, added for consistency with subplots.

  • order ({'C', 'F'}, optional) – Whether legend handles are drawn in row-major ('C') or column-major ('F') order. Analagous to numpy.array ordering. Default is 'F'.

  • center (bool, optional) – Whether to center each legend row individually. If True, we draw successive single-row legends stacked on top of each other. If None, we infer this setting from handles. By default, center is set to True if handles is 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 is False.

  • title, label (str, optional) – The legend title. The label keyword is also accepted, for consistency with colorbar.

  • fontsize, fontweight, fontcolor (optional) – The font size, weight, and color for the legend text. Font size is interpreted by units. The default font size is rc['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 is fontsize.

  • borderpad, borderaxespad, handlelength, handleheight, handletextpad, labelspacing, columnspacing (unit-spec, optional) – Various matplotlib legend spacing arguments. If float, units are em-widths. If string, interpreted by units.

  • 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' and rc['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_map updates the default handler map found at matplotlib.legend.Legend.get_legend_handler_map.

  • **kwargs – Passed to legend.

save(filename, **kwargs)[source]

Save the figure.

Parameters
savefig(filename, **kwargs)[source]

Save the figure.

Parameters
set_canvas(canvas)[source]

Set the figure canvas. Add monkey patches for the instance-level draw and print_figure methods.

Parameters

canvas (FigureCanvasBase) – The figure canvas.

set_constrained_layout(constrained)[source]

Set whether constrained_layout is 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_pad the default constrained_layout paddings will be overridden. These pads are in inches and default to 3.0/72.0. w_pad is the width padding and h_pad is the height padding.

See /tutorials/intermediate/constrainedlayout_guide.

Parameters

constrained (bool or dict or None)

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_layout is called when drawing.

Parameters

tight (bool or dict with keys "pad", "w_pad", "h_pad", "rect" or None) – If a bool, sets whether to call tight_layout upon drawing. If None, use the figure.autolayout rcparam instead. If a dict, pass it as kwargs to tight_layout, overriding the default paddings.

subplot(*args, **kwargs)[source]

Add a subplot axes to the figure.

Parameters
  • *args (int, tuple, or SubplotSpec, 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 SubplotSpec instance generated by indexing a ProPlot GridSpec.

    For integer input, the implied geometry must be compatible with the implied geometry from previous calls – for example, fig.add_subplot(331) followed by fig.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, but fig.add_subplot(232) will raise an error because 2 rows cannot be tiled into 3 rows. For SubplotSpec input, the SubplotSpec must be derived from the GridSpec used in previous calls.

    These restrictions arise because we allocate a single, unique gridspec for each figure.

  • number (int, optional) – The axes number used for a-b-c labeling. See format for details. By default this is incremented automatically based on the other subplots in the figure. Use 0 or False to ensure the subplot has no a-b-c label. Note the number corresponding to a is 1, not 0.

  • autoshare (bool, optional) – Whether to automatically share the x and y axes with subplots spanning the same rows and columns based on the figure-wide sharex and sharey settings. Default is True. This has no effect if rc['subplots.share'] is False or if sharex=False or sharey=False were passed to the figure.

  • proj, projection (str, cartopy.crs.Projection, or Basemap, optional) – The map projection specification(s). If 'cart' or 'cartesian' (the default), a CartesianAxes is created. If 'polar', a PolarAxes is created. Otherwise, the argument is interpreted by Proj, and the result is used to make a GeoAxes (in this case the argument can be a cartopy.crs.Projection instance, a Basemap instance, or a projection name listed in this table).

  • proj_kw, projection_kw (dict-like, optional) – Keyword arguments passed to Basemap or cartopy Projection classes on instantiation.

  • basemap (bool or dict-like, optional) – Whether to use Basemap or Projection for map projections. Default is rc.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, and 0 indicates 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 if array was 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 to numpy.array ordering. This controls the order that subplots appear in the SubplotGrid returned by this function, and the order of subplot a-b-c labels (see format).

  • proj, projection (str, cartopy.crs.Projection, or Basemap, optional) – The map projection specification(s). If 'cart' or 'cartesian' (the default), a CartesianAxes is created. If 'polar', a PolarAxes is created. Otherwise, the argument is interpreted by Proj, and the result is used to make a GeoAxes (in this case the argument can be a cartopy.crs.Projection instance, a Basemap instance, 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 Basemap or cartopy Projection classes on instantiation. If dictionary of properties, applies globally. If list or dictionary of dictionaries, applies to specific subplots, as with proj. 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 (bool or dict-like, optional) – Whether to use Basemap or Projection for map projections. Default is rc.basemap = False. If boolean, applies to all subplots. If list or dict, applies to specific subplots, as with proj.

  • left, right, top, bottom (unit-spec, optional) – The fixed space between the subplots and the figure edge. Default is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, the space is determined by the tight layout algorithm.

  • wspace, hspace, space (unit-spec or sequence, optional) – The fixed space between grid columns, rows, and both, respectively. If float, string, or None, this value is expanded into lists of length ncols - 1 (for wspace) or length nrows - 1 (for hspace). If a sequence, its length must match these lengths. Default is None. If float, units are em-widths. If string, interpreted by units.

    For sequence elements equal to None, the space is determined automatically based on the font size and axis settings. If rc['subplots.tight'] is True, 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 (float or sequence, optional) – Passed to GridSpec, denotes the width and height ratios for the subplot grid. Length of wratios must match the number of rows, and length of hratios must match the number of columns.

  • width_ratios, height_ratios – Aliases for wratios, hratios. Included for consistency with the matplotlib.pyplot.subplots command.

  • wpad, hpad, pad (unit-spec or sequence, optional) – The tight layout padding between columns, rows, and both, respectively. Unlike space, these control the padding between subplot content (including text, ticks, etc.) rather than subplot edges. As with space, these can be scalars or arrays optionally containing None. Default is innerpad. If float, units are em-widths. If string, interpreted by units.

  • wequal, hequal, equal (bool, optional) – Whether to make the tight layout algorithm apply equal spacing between columns, rows, or both. Default is False. Ignored if rc.tight is False.

  • outerpad (unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default is rc['subplots.outerpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • innerpad (unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous with pad. Default is rc['subplots.innerpad'] = 1.0. If float, units are em-widths. If string, interpreted by units.

  • panelpad (unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default is rc['subplots.panelpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

Other Parameters
  • refnum (int, optional) – The reference subplot number. The refwidth, refheight, and refaspect keyword args are applied to this subplot, and the aspect ratio is conserved for this subplot in the auto_layout. The default is the first subplot created in the figure.

  • refaspect (float or 2-tuple of float, optional) – The reference subplot aspect ratio. If scalar, this indicates the width divided by height. If 2-tuple, indicates the (width, height). Ignored if both figwidth and figheight or both refwidth and refheight were passed.

  • refwidth, refheight (unit-spec, optional) – The width, height of the reference subplot. Default is rc['subplots.refwidth'] = 2.5. If float, units are inches. If string, interpreted by units. Ignored if figwidth, figheight, or figsize was passed. If you specify just one, refaspect will 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 use refwidth. If float, units are inches. If string, interpreted by units. If you specify just one, refaspect will 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 is rc['subplots.share'] = True. Options are as follows:

    • 0 or False: No axis sharing. This also sets the default spanx and spany values to False.

    • 1 or 'labels' or 'labs': Only draw axis labels on the bottommost row or leftmost column of subplots. Tick labels still appear on every subplot.

    • 2 or 'limits' or 'lims': As above but force the axis limits, scales, and tick locations to be identical. Tick labels still appear on every subplot.

    • 3 or True: As above but only show the tick labels on the bottommost row and leftmost column of subplots.

    • 4 or '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 (bool or {0, 1}, optional) – Whether to use “spanning” axis labels for the x axis, y axis, or both axes. Default is False if sharex, sharey, or share are 0 or False, rc['subplots.span'] = True otherwise. When True, 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 > 1 and spany=1, your figure will have 1 ylabel instead of 9.

  • alignx, aligny, align (bool or {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 when spanx, spany, or span are False. Default is rc['subplots.align'] = False.

  • left, right, top, bottom (unit-spec, optional) – The fixed space between the subplots and the figure edge. Default is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, 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 is None. If float, units are em-widths. If string, interpreted by units. If None, the space is determined automatically based on the font size and axis sharing settings. If rc['subplots.tight'] is True, the space is determined by the tight layout algorithm.

  • tight (bool, optional) – Whether to have auto_layout include tight layout adjustments. Default is rc['subplots.tight'] = True. If you manually specified a spacing in the call to subplots, it will be used to override the tight layout spacing. For example, with left=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 is False. Ignored if rc.tight is False.

  • outerpad (unit-spec, optional) – The tight layout padding around the left, right, top, and bottom edges of the figure. Default is rc['subplots.outerpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • innerpad (unit-spec, optional) – The scalar tight layout padding between columns and rows. Synonymous with pad. Default is rc['subplots.innerpad'] = 1.0. If float, units are em-widths. If string, interpreted by units.

  • panelpad (unit-spec, optional) – The tight layout padding between subplots and axes panels and between “stacked” panels. Default is rc['subplots.panelpad'] = 0.5. If float, units are em-widths. If string, interpreted by units.

  • includepanels (bool, optional) – Whether to include panels when aligning figure “super titles” along the top of the subplot grid and when aligning the spanx x axis labels and spany y axis labels along the sides of the subplot grid. Default is False.

  • mathtext_fallback (bool or str, optional) – Apply this rc['mathtext.fallback'] value when drawing the figure. If True or 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 width figwidth and, if specified, the figure height figheight. 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

    American Geophysical Union

    'agu2'

    2-column

    'agu3'

    full height 1-column

    'agu4'

    full height 2-column

    'ams1'

    1-column

    American Meteorological Society

    'ams2'

    small 2-column

    'ams3'

    medium 2-column

    'ams4'

    full 2-column

    'nat1'

    1-column

    Nature Research

    'nat2'

    2-column

    'pnas1'

    1-column

    Proceedings of the National Academy of Sciences

    'pnas2'

    2-column

    'pnas3'

    landscape page

  • **kwargs – Passed to Figure.add_subplot.

Returns

axs (SubplotGrid) – The axes instances stored in a SubplotGrid.

subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)[source]

Update the SubplotParams with 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 (subclass of RendererBase, 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