Align the titles of subplots in the same subplot row if title alignment is being done automatically (i.e. the title position is not manually set). Alignment persists for draw events after this is called. Parameters ---------- axs : list of `
(self, axs=None)
| 1486 | self._align_label_groups['y'].join(ax, axc) |
| 1487 | |
| 1488 | def align_titles(self, axs=None): |
| 1489 | """ |
| 1490 | Align the titles of subplots in the same subplot row if title |
| 1491 | alignment is being done automatically (i.e. the title position is |
| 1492 | not manually set). |
| 1493 | |
| 1494 | Alignment persists for draw events after this is called. |
| 1495 | |
| 1496 | Parameters |
| 1497 | ---------- |
| 1498 | axs : list of `~matplotlib.axes.Axes` |
| 1499 | Optional list of (or ndarray) `~matplotlib.axes.Axes` |
| 1500 | to align the titles. |
| 1501 | Default is to align all Axes on the figure. |
| 1502 | |
| 1503 | See Also |
| 1504 | -------- |
| 1505 | matplotlib.figure.Figure.align_xlabels |
| 1506 | matplotlib.figure.Figure.align_ylabels |
| 1507 | matplotlib.figure.Figure.align_labels |
| 1508 | |
| 1509 | Notes |
| 1510 | ----- |
| 1511 | This assumes that all Axes in ``axs`` are from the same `.GridSpec`, |
| 1512 | so that their `.SubplotSpec` positions correspond to figure positions. |
| 1513 | |
| 1514 | Examples |
| 1515 | -------- |
| 1516 | Example with titles:: |
| 1517 | |
| 1518 | fig, axs = plt.subplots(1, 2) |
| 1519 | axs[0].set_aspect('equal') |
| 1520 | axs[0].set_title('Title 0') |
| 1521 | axs[1].set_title('Title 1') |
| 1522 | fig.align_titles() |
| 1523 | """ |
| 1524 | if axs is None: |
| 1525 | axs = self.axes |
| 1526 | axs = [ax for ax in np.ravel(axs) if ax.get_subplotspec() is not None] |
| 1527 | for ax in axs: |
| 1528 | _log.debug(' Working on: %s', ax.get_title()) |
| 1529 | rowspan = ax.get_subplotspec().rowspan |
| 1530 | for axc in axs: |
| 1531 | rowspanc = axc.get_subplotspec().rowspan |
| 1532 | if (rowspan.start == rowspanc.start): |
| 1533 | self._align_label_groups['title'].join(ax, axc) |
| 1534 | |
| 1535 | def align_labels(self, axs=None): |
| 1536 | """ |