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.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 3. This can considerably reduce redundancy in your figure. 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, 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) – Default is False. 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.

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

See also

Figure

Attributes Summary

gridspec

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

ref

The reference axes number.

Methods Summary

add_subplot(*args, **kwargs)

Issues warning for new users that try to call add_subplot manually.

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.

get_alignx()

Return the x axis label alignment mode.

get_aligny()

Return the y axis label alignment mode.

get_sharex()

Return the x axis sharing level.

get_sharey()

Return the y axis sharing level.

get_spanx()

Return the x axis label spanning mode.

get_spany()

Return the y axis label spanning mode.

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.

set_alignx(value)

Set the x axis label alignment mode.

set_aligny(value)

Set the y axis label alignment mode.

set_sharex(value)

Set the x axis sharing level.

set_sharey(value)

Set the y axis sharing level.

set_spanx(value)

Set the x axis label spanning mode.

set_spany(value)

Set the y axis label spanning mode.