Adjust the padding between and around subplots. To exclude an artist on the Axes from the bounding box calculation that determines the subplot parameters (i.e. legend, or annotation), set ``a.set_in_layout(False)`` for that artist. Parameters ------
(self, *, pad=1.08, h_pad=None, w_pad=None, rect=None)
| 3631 | return None if event is None else event.name == "key_press_event" |
| 3632 | |
| 3633 | def tight_layout(self, *, pad=1.08, h_pad=None, w_pad=None, rect=None): |
| 3634 | """ |
| 3635 | Adjust the padding between and around subplots. |
| 3636 | |
| 3637 | To exclude an artist on the Axes from the bounding box calculation |
| 3638 | that determines the subplot parameters (i.e. legend, or annotation), |
| 3639 | set ``a.set_in_layout(False)`` for that artist. |
| 3640 | |
| 3641 | Parameters |
| 3642 | ---------- |
| 3643 | pad : float, default: 1.08 |
| 3644 | Padding between the figure edge and the edges of subplots, |
| 3645 | as a fraction of the font size. |
| 3646 | h_pad, w_pad : float, default: *pad* |
| 3647 | Padding (height/width) between edges of adjacent subplots, |
| 3648 | as a fraction of the font size. |
| 3649 | rect : tuple (left, bottom, right, top), default: (0, 0, 1, 1) |
| 3650 | A rectangle in normalized figure coordinates into which the whole |
| 3651 | subplots area (including labels) will fit. |
| 3652 | |
| 3653 | See Also |
| 3654 | -------- |
| 3655 | .Figure.set_layout_engine |
| 3656 | .pyplot.tight_layout |
| 3657 | """ |
| 3658 | # note that here we do not permanently set the figures engine to |
| 3659 | # tight_layout but rather just perform the layout in place and remove |
| 3660 | # any previous engines. |
| 3661 | engine = TightLayoutEngine(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect) |
| 3662 | try: |
| 3663 | previous_engine = self.get_layout_engine() |
| 3664 | self.set_layout_engine(engine) |
| 3665 | engine.execute(self) |
| 3666 | if previous_engine is not None and not isinstance( |
| 3667 | previous_engine, (TightLayoutEngine, PlaceHolderLayoutEngine) |
| 3668 | ): |
| 3669 | _api.warn_external('The figure layout has changed to tight') |
| 3670 | finally: |
| 3671 | self.set_layout_engine('none') |
| 3672 | |
| 3673 | |
| 3674 | def figaspect(arg): |