MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / subfigures

Method subfigures

lib/matplotlib/figure.py:1611–1678  ·  view source on GitHub ↗

Add a set of subfigures to this figure or subfigure. A subfigure has the same artist methods as a figure, and is logically the same as a figure, but cannot print itself. See :doc:`/gallery/subplots_axes_and_figures/subfigures`. .. versionchanged:: 3.10

(self, nrows=1, ncols=1, squeeze=True,
                   wspace=None, hspace=None,
                   width_ratios=None, height_ratios=None,
                   **kwargs)

Source from the content-addressed store, hash-verified

1609 return gs
1610
1611 def subfigures(self, nrows=1, ncols=1, squeeze=True,
1612 wspace=None, hspace=None,
1613 width_ratios=None, height_ratios=None,
1614 **kwargs):
1615 """
1616 Add a set of subfigures to this figure or subfigure.
1617
1618 A subfigure has the same artist methods as a figure, and is logically
1619 the same as a figure, but cannot print itself.
1620 See :doc:`/gallery/subplots_axes_and_figures/subfigures`.
1621
1622 .. versionchanged:: 3.10
1623 subfigures are now added in row-major order.
1624
1625 Parameters
1626 ----------
1627 nrows, ncols : int, default: 1
1628 Number of rows/columns of the subfigure grid.
1629
1630 squeeze : bool, default: True
1631 If True, extra dimensions are squeezed out from the returned
1632 array of subfigures.
1633
1634 wspace, hspace : float, default: None
1635 The amount of width/height reserved for space between subfigures,
1636 expressed as a fraction of the average subfigure width/height.
1637 If not given, the values will be inferred from rcParams if using
1638 constrained layout (see `~.ConstrainedLayoutEngine`), or zero if
1639 not using a layout engine.
1640
1641 width_ratios : array-like of length *ncols*, optional
1642 Defines the relative widths of the columns. Each column gets a
1643 relative width of ``width_ratios[i] / sum(width_ratios)``.
1644 If not given, all columns will have the same width.
1645
1646 height_ratios : array-like of length *nrows*, optional
1647 Defines the relative heights of the rows. Each row gets a
1648 relative height of ``height_ratios[i] / sum(height_ratios)``.
1649 If not given, all rows will have the same height.
1650 """
1651 gs = GridSpec(nrows=nrows, ncols=ncols, figure=self,
1652 wspace=wspace, hspace=hspace,
1653 width_ratios=width_ratios,
1654 height_ratios=height_ratios,
1655 left=0, right=1, bottom=0, top=1)
1656
1657 sfarr = np.empty((nrows, ncols), dtype=object)
1658 for i in range(nrows):
1659 for j in range(ncols):
1660 sfarr[i, j] = self.add_subfigure(gs[i, j], **kwargs)
1661
1662 if self.get_layout_engine() is None and (wspace is not None or
1663 hspace is not None):
1664 # Gridspec wspace and hspace is ignored on subfigure instantiation,
1665 # and no space is left. So need to account for it here if required.
1666 bottoms, tops, lefts, rights = gs.get_grid_positions(self)
1667 for sfrow, bottom, top in zip(sfarr, bottoms, tops):
1668 for sf, left, right in zip(sfrow, lefts, rights):

Callers 15

test_subfigure_simpleFunction · 0.80
plot_pathsFunction · 0.80
_save_figureFunction · 0.80
test_ttc_type3Function · 0.80
test_ttc_type42Function · 0.80
test_ttc_type3Function · 0.80
test_ttc_type42Function · 0.80
test_subfigure_legendFunction · 0.80

Calls 6

add_subfigureMethod · 0.95
GridSpecClass · 0.90
get_grid_positionsMethod · 0.80
from_extentsMethod · 0.80
get_layout_engineMethod · 0.45

Tested by 15

test_subfigure_simpleFunction · 0.64
plot_pathsFunction · 0.64
_save_figureFunction · 0.64
test_ttc_type3Function · 0.64
test_ttc_type42Function · 0.64
test_ttc_type3Function · 0.64
test_ttc_type42Function · 0.64
test_subfigure_legendFunction · 0.64