Low-level API for creating a `.GridSpec` that has this figure as a parent. This is a low-level API, allowing you to create a gridspec and subsequently add subplots based on the gridspec. Most users do not need that freedom and should use the higher-level methods
(self, nrows=1, ncols=1, **kwargs)
| 1562 | self.align_ylabels(axs=axs) |
| 1563 | |
| 1564 | def add_gridspec(self, nrows=1, ncols=1, **kwargs): |
| 1565 | """ |
| 1566 | Low-level API for creating a `.GridSpec` that has this figure as a parent. |
| 1567 | |
| 1568 | This is a low-level API, allowing you to create a gridspec and |
| 1569 | subsequently add subplots based on the gridspec. Most users do |
| 1570 | not need that freedom and should use the higher-level methods |
| 1571 | `~.Figure.subplots` or `~.Figure.subplot_mosaic`. |
| 1572 | |
| 1573 | Parameters |
| 1574 | ---------- |
| 1575 | nrows : int, default: 1 |
| 1576 | Number of rows in grid. |
| 1577 | |
| 1578 | ncols : int, default: 1 |
| 1579 | Number of columns in grid. |
| 1580 | |
| 1581 | Returns |
| 1582 | ------- |
| 1583 | `.GridSpec` |
| 1584 | |
| 1585 | Other Parameters |
| 1586 | ---------------- |
| 1587 | **kwargs |
| 1588 | Keyword arguments are passed to `.GridSpec`. |
| 1589 | |
| 1590 | See Also |
| 1591 | -------- |
| 1592 | matplotlib.pyplot.subplots |
| 1593 | |
| 1594 | Examples |
| 1595 | -------- |
| 1596 | Adding a subplot that spans two rows:: |
| 1597 | |
| 1598 | fig = plt.figure() |
| 1599 | gs = fig.add_gridspec(2, 2) |
| 1600 | ax1 = fig.add_subplot(gs[0, 0]) |
| 1601 | ax2 = fig.add_subplot(gs[1, 0]) |
| 1602 | # spans two rows: |
| 1603 | ax3 = fig.add_subplot(gs[:, 1]) |
| 1604 | |
| 1605 | """ |
| 1606 | |
| 1607 | _ = kwargs.pop('figure', None) # pop in case user has added this... |
| 1608 | gs = GridSpec(nrows=nrows, ncols=ncols, figure=self, **kwargs) |
| 1609 | return gs |
| 1610 | |
| 1611 | def subfigures(self, nrows=1, ncols=1, squeeze=True, |
| 1612 | wspace=None, hspace=None, |