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 bysubplots
. 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 tosubplots
, it will be used to override the tight layout spacing. For example, withleft=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 is1
.pad (float or str, optional) – Padding around edge of figure. Units are interpreted by
units
. Default isrc[‘subplots.pad’]
='0.5em'
.axpad (float or str, optional) – Padding between subplots in adjacent columns and rows. Units are interpreted by
units
. Default isrc[‘subplots.axpad’]
='1em'
.panelpad (float or str, optional) – Padding between subplots and axes panels, and between “stacked” panels. Units are interpreted by
units
. Default isrc[‘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:No axis sharing. Also sets the default
spanx
andspany
values toFalse
.Only draw axis label on the leftmost column (y) or bottommost row (x) of subplots. Axis tick labels still appear on every subplot.
As in 1, but forces the axis limits to be identical. Axis tick labels still appear on every subplot.
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
ifsharex
,sharey
, orshare
are0
,rc[‘subplots.span’]
=True
otherwise. 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 > 1
andspany=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
, orspan
areFalse
. Default isrc[‘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
orDataArray
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
The x axis label alignment mode.
The y axis label alignment mode.
The single
GridSpec
instance used for all subplots in the figure.The reference axes number.
The x axis sharing level.
The y axis sharing level.
The x axis label spanning mode.
The y axis label spanning mode.
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
.