subplots¶
-
subplots
(array=None, ncols=1, nrows=1, ref=1, order='C', aspect=1, figsize=None, width=None, height=None, journal=None, axwidth=None, axheight=None, hspace=None, wspace=None, space=None, hratios=None, wratios=None, width_ratios=None, height_ratios=None, flush=None, wflush=None, hflush=None, left=None, bottom=None, right=None, top=None, tight=None, pad=None, axpad=None, panelpad=None, span=None, spanx=None, spany=None, align=None, alignx=None, aligny=None, share=None, sharex=None, sharey=None, basemap=False, proj=None, projection=None, proj_kw=None, projection_kw=None, autoformat=True, includepanels=False)[source]¶ Analogous to
matplotlib.pyplot.subplots
, creates a figure with a single axes or arbitrary grids of axes, any of which can be map projections.- Parameters
array (2D array-like of int, optional) – Array specifying complex grid of subplots. Think of this array 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.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) – Number of columns, rows. Ignored if
array
is notNone
. 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 tonumpy.array
ordering. This controls the order axes appear in theaxs
list, and the order of subplot a-b-c labeling (seeformat
).figsize (length-2 tuple, optional) – Tuple specifying the figure
(width, height)
.width, height (float or str, optional) – The figure width and height. Units are interpreted by
units
.journal (str, optional) – String name corresponding to an academic journal standard that is used to control the figure width (and height, if specified). See below table.
Key
Size description
Organization
'pnas1'
1-column
'pnas2'
2-column
”
'pnas3'
landscape page
”
'ams1'
1-column
'ams2'
small 2-column
”
'ams3'
medium 2-column
”
'ams4'
full 2-column
”
'agu1'
1-column
'agu2'
2-column
”
'agu3'
full height 1-column
”
'agu4'
full height 2-column
”
ref (int, optional) – The reference axes number. The
axwidth
,axheight
, andaspect
keyword args are applied to this axes, and aspect ratio is conserved for this axes in tight layout adjustment.axwidth, axheight (float or str, optional) – Sets the average width, height of your axes. Units are interpreted by
units
. Default isrc[‘subplots.axwidth’]
='18em'
.These arguments are convenient where you don’t care about the figure dimensions and just want your axes to have enough “room”.
aspect (float or length-2 list of floats, optional) – The (average) axes aspect ratio, in numeric form (width divided by height) or as (width, height) tuple. If you do not provide the
hratios
orwratios
keyword args, all axes will have identical aspect ratios.hratios, wratios – Aliases for
height_ratios
,width_ratios
.width_ratios, height_ratios (float or list thereof, optional) – Passed to
GridSpec
, denotes the width and height ratios for the subplot grid. Length ofwidth_ratios
must match the number of rows, and length ofheight_ratios
must match the number of columns.wspace, hspace, space (float or str or list thereof, optional) – Passed to
GridSpec
, denotes the spacing between grid columns, rows, and both, respectively. If float or string, expanded into lists of lengthncols-1
(forwspace
) or lengthnrows-1
(forhspace
).Units are interpreted by
units
for each element of the list. By default, these are determined by the “tight layout” algorithm.left, right, top, bottom (float or str, optional) – Passed to
GridSpec
, denotes the width of padding between the subplots and the figure edge. Units are interpreted byunits
. By default, these are determined by the “tight layout” algorithm.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 redundancy in your figure. The 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) – Default is
False
ifsharex
,sharey
, orshare
are0
,True
otherwise. Toggles “spanning” axis labels for the x axis, y axis, or both axes. 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) – Default is
False
. Whether to align axis labels for the x axis, y axis, or both axes. Only has an effect whenspanx
,spany
, orspan
areFalse
.proj, projection (str or dict-like, optional) – The map projection name. The argument is interpreted as follows.
If string, this projection is used for all subplots. For valid names, see the
Proj
documentation.If list of string, these are the projections to use for each subplot in their
array
order.If dict-like, keys are integers or tuple integers that indicate the projection to use for each subplot. If a key is not provided, that subplot will be a
XYAxes
. For example, in a 4-subplot figure,proj={2:'merc', (3,4):'stere'}
draws a Cartesian axes for the first subplot, a Mercator projection for the second subplot, and a Stereographic projection for the second and third subplots.
proj_kw, projection_kw (dict-like, optional) – Keyword arguments passed to
Basemap
or cartopyProjection
classes on instantiation. If dictionary of properties, applies globally. If dictionary of dictionaries of properties, applies to specific subplots, as withproj
.For example, with
ncols=2
andproj_kw={1:{'lon_0':0}, 2:{'lon_0':180}}
, the projection in the left subplot is centered on the prime meridian, and the projection in the right subplot is centered on the international dateline.basemap (bool or dict-like, optional) – Whether to use
Basemap
orProjection
for map projections. Default isFalse
. If boolean, applies to all subplots. If dictionary, values apply to specific subplots, as withproj
.
- Other Parameters
tight (bool, optional) – Toggles automatic tight layout adjustments. Default is
rc.tight
=True
.If you manually specify a spacing, 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.pad, axpad, panelpad (float or str, optional) – Padding for automatic tight layout adjustments. See
Figure
for details.includepanels (bool, optional) – Whether to include panels when calculating the position of certain spanning labels. See
Figure
for details.autoformat (bool, optional) – Whether to automatically format axes when special datasets are passed to plotting commands. See
Figure
for details.
- Returns
f (
Figure
) – The figure instance.axs (
subplot_grid
) – A special list of axes instances. Seesubplot_grid
.