Figure¶
- class Figure[source]¶
Bases:
matplotlib.figure.Figure
The
Figure
subclass used by proplot.- Parameters
refnum (
int
, optional) – The reference subplot number. Therefwidth
,refheight
, andrefaspect
keyword 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 (
float
or2-tuple
offloat
, optional) – The reference subplot aspect ratio. If scalar, this indicates the width divided by height. If 2-tuple, indicates the (width, height). Ignored if bothfigwidth
andfigheight
or bothrefwidth
andrefheight
were 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
, orfigsize
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 userefwidth
. If float, units are inches. If string, interpreted byunits
. 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 isrc['subplots.share']
=True
. Options are as follows:0
orFalse
: No axis sharing. This also sets the defaultspanx
andspany
values toFalse
.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
orTrue
: 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 isFalse
ifsharex
,sharey
, orshare
are0
orFalse
,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. Aligned labels always appear in the same row or column. This Only has an effect whenspanx
,spany
, orspan
areFalse
. 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 tick and label settings. Ifrc['subplots.tight']
isTrue
ortight=True
was passed to the figure, 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
ortight=True
was passed to the figure, the space is determined by the tight layout algorithm.tight (
bool
, optional) – Whether to haveauto_layout
include 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
.outerpad (
unit-spec
, optional) – The scalar 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 scalar tight layout padding between subplots and their panels, colorbars, and legends and between “stacks” of these objects. Default isrc['subplots.panelpad']
=0.5
. If float, units are em-widths. If string, interpreted byunits
.journal (
str
, optional) – String corresponding to an academic journal standard used to control the figure widthfigwidth
and, 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
rowlabels, collabels, llabels, tlabels, rlabels, blabels – Aliases for
leftlabels
andtoplabels
, and forleftlabels
,toplabels
,rightlabels
, andbottomlabels
, respectively.leftlabels, toplabels, rightlabels, bottomlabels (sequence of
str
, optional) – Labels for the subplots lying along the left, top, right, and bottom edges of the figure. The length of each list must match the number of subplots along the corresponding edge.leftlabelpad, toplabelpad, rightlabelpad, bottomlabelpad (
float
, optional) – The padding between the labels and the axes content in arbitrary units (default is points). Defaults arerc['leftlabel.pad']
,rc['toplabel.pad']
,rc['rightlabel.pad']
, andrc['bottomlabel.pad']
leftlabels_kw, toplabels_kw, rightlabels_kw, bottomlabels_kw (dict-like, optional) – Additional settings used to update the labels with
text.update()
.figtitle – Alias for
suptitle
.suptitle (
str
, optional) – The figure “super” title, centered between the left edge of the lefmost column of subplots and the right edge of the rightmost column of subplots, and automatically offset above figure titles. This is an improvement on matplotlib’s “super” title, which just centers the text between figure edges.suptitlepad (
float
, optional) – The padding between the super title and the axes content in arbitrary units (default is points). Default isrc['suptitle.pad']
.suptitle_kw (optional) – Additional settings used to update the super title with
text.update()
.includepanels (
bool
, optional) – Whether to include panels when aligning figure “super titles” along the top of the subplot grid and when aligning thespanx
x axis labels andspany
y axis labels along the sides of the subplot grid. Default isFalse
.mathtext_fallback (
bool
orstr
, optional) – Apply thisrc['mathtext.fallback']
value when drawing the figure. IfTrue
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.**kwargs – Passed to
matplotlib.figure.Figure
.
Attributes Summary
The single
GridSpec
instance used for all subplots in the figure.A
SubplotGrid
containing 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.
format
()Modify figure-wide labels and call
format
for the input axes.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_size_inches
(w[, h, forward, internal, eps])Set the figure size.
subplot
(*args, **kwargs)Add a subplot axes to the figure.
subplots
(*args, **kwargs)Add an arbitrary grid of subplots to the figure.