Reposition all the Axes based on the new inner bounding box.
(layoutgrids, fig, renderer, *,
w_pad=0, h_pad=0, hspace=0, wspace=0, compress=False)
| 643 | |
| 644 | |
| 645 | def reposition_axes(layoutgrids, fig, renderer, *, |
| 646 | w_pad=0, h_pad=0, hspace=0, wspace=0, compress=False): |
| 647 | """ |
| 648 | Reposition all the Axes based on the new inner bounding box. |
| 649 | """ |
| 650 | trans_fig_to_subfig = fig.transFigure - fig.transSubfigure |
| 651 | for sfig in fig.subfigs: |
| 652 | bbox = layoutgrids[sfig].get_outer_bbox() |
| 653 | sfig._redo_transform_rel_fig( |
| 654 | bbox=bbox.transformed(trans_fig_to_subfig)) |
| 655 | reposition_axes(layoutgrids, sfig, renderer, |
| 656 | w_pad=w_pad, h_pad=h_pad, |
| 657 | wspace=wspace, hspace=hspace, compress=compress) |
| 658 | |
| 659 | for ax in fig._localaxes: |
| 660 | if ax.get_subplotspec() is None or not ax.get_in_layout(): |
| 661 | continue |
| 662 | |
| 663 | # grid bbox is in Figure coordinates, but we specify in panel |
| 664 | # coordinates... |
| 665 | ss = ax.get_subplotspec() |
| 666 | gs = ss.get_gridspec() |
| 667 | if gs not in layoutgrids: |
| 668 | return |
| 669 | |
| 670 | bbox = layoutgrids[gs].get_inner_bbox(rows=ss.rowspan, |
| 671 | cols=ss.colspan) |
| 672 | |
| 673 | # transform from figure to panel for set_position: |
| 674 | newbbox = trans_fig_to_subfig.transform_bbox(bbox) |
| 675 | ax._set_position(newbbox) |
| 676 | |
| 677 | # move the colorbars: |
| 678 | # we need to keep track of oldw and oldh if there is more than |
| 679 | # one colorbar: |
| 680 | offset = {'left': 0, 'right': 0, 'bottom': 0, 'top': 0} |
| 681 | for nn, cbax in enumerate(ax._colorbars[::-1]): |
| 682 | if ax == cbax._colorbar_info['parents'][0]: |
| 683 | reposition_colorbar(layoutgrids, cbax, renderer, |
| 684 | offset=offset, compress=compress) |
| 685 | |
| 686 | |
| 687 | def reposition_colorbar(layoutgrids, cbax, renderer, *, offset=None, compress=False): |
no test coverage detected
searching dependent graphs…