Figure

class Figure(tight=None, ref=1, pad=None, axpad=None, panelpad=None, includepanels=False, span=None, spanx=None, spany=None, align=None, alignx=None, aligny=None, share=None, sharex=None, sharey=None, autoformat=True, fallback_to_cm=None, gridspec_kw=None, subplots_kw=None, subplots_orig_kw=None, **kwargs)[source]

Bases: matplotlib.figure.Figure

The Figure class returned by subplots. At draw-time, an improved tight layout algorithm is employed, and the space around the figure edge, between subplots, and between panels is changed to accommodate subplot content. Figure dimensions may be automatically scaled to preserve subplot aspect ratios.

Parameters
  • tight (bool, optional) – Toggles automatic 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=0.1, the left margin is set to 0.1 inches wide, while the remaining margin widths are calculated automatically.

  • ref (int, optional) – The reference subplot number. See subplots for details. Default is 1.

  • pad (float or str, optional) – Padding around edge of figure. Units are interpreted by units. Default is rc[‘subplots.pad’] = '0.5em'.

  • axpad (float or str, optional) – Padding between subplots in adjacent columns and rows. Units are interpreted by units. Default is rc[‘subplots.axpad’] = '1em'.

  • panelpad (float or str, optional) – Padding between subplots and axes panels, and between “stacked” panels. Units are interpreted by units. Default is rc[‘subplots.panelpad’] = '0.5em'.

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

  • sharex, sharey, share ({3, 2, 1, 0}, optional) – The “axis sharing level” for the x axis, y axis, or both axes. Default is rc[‘subplots.share’] = 3. Options are as follows:

    1. No axis sharing. Also sets the default spanx and spany values to False.

    2. Only draw axis label on the leftmost column (y) or bottommost row (x) of subplots. Axis tick labels still appear on every subplot.

    3. As in 1, but forces the axis limits to be identical. Axis tick labels still appear on every subplot.

    4. As in 2, but only show the axis tick labels on the leftmost column (y) or bottommost row (x) of subplots.

  • spanx, spany, span (bool or {0, 1}, optional) – Toggles “spanning” axis labels for the x axis, y axis, or both axes. Default is False if sharex, sharey, or share are 0, 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. Only has an effect when spanx, spany, or span are False. Default is rc[‘subplots.align’] = False.

  • autoformat (bool, optional) – Whether to automatically configure x axis labels, y axis labels, axis formatters, axes titles, colorbar labels, and legend labels when a Series, DataFrame or DataArray with relevant metadata is passed to a plotting command.

  • fallback_to_cm (bool, optional) – Whether to replace unavailable glyphs with a glyph from Computer Modern or the “¤” dummy character. See mathtext for details.

  • gridspec_kw, subplots_kw, subplots_orig_kw – Keywords used for initializing the main gridspec, for initializing the figure, and original spacing keyword args used for initializing the figure that override tight layout spacing.

Other Parameters

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

Attributes Summary

alignx

The x axis label alignment mode.

aligny

The y axis label alignment mode.

gridspec

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

ref

The reference axes number.

sharex

The x axis sharing level.

sharey

The y axis sharing level.

spanx

The x axis label spanning mode.

spany

The y axis label spanning mode.

tight

Whether subplot spacing is determined automatically for spaces that were not explicitly fixed by the user.

Methods Summary

auto_layout([renderer, resize, aspect, tight])

Trigger proplot’s automatic figure size and tight layout algorithm.

colorbar(*args[, loc, width, space, row, …])

Draw a colorbar along the left, right, bottom, or top side of the figure, centered between the leftmost and rightmost (or topmost and bottommost) main axes.

legend(*args[, loc, width, space, row, col, …])

Draw a legend along the left, right, bottom, or top side of the figure, centered between the leftmost and rightmost (or topmost and bottommost) main axes.

save(filename, **kwargs)

Alias for savefig.