Return the tight bounding box of the Axes, including axis and their decorators (xlabel, title, etc). Artists that have ``artist.set_in_layout(False)`` are not included in the bbox. Parameters ---------- renderer : `.RendererBase` subclass
(self, renderer=None, *, call_axes_locator=True,
bbox_extra_artists=None, for_layout_only=False)
| 4682 | and (isinstance(a, noclip) or not a._fully_clipped_to_axes())] |
| 4683 | |
| 4684 | def get_tightbbox(self, renderer=None, *, call_axes_locator=True, |
| 4685 | bbox_extra_artists=None, for_layout_only=False): |
| 4686 | """ |
| 4687 | Return the tight bounding box of the Axes, including axis and their |
| 4688 | decorators (xlabel, title, etc). |
| 4689 | |
| 4690 | Artists that have ``artist.set_in_layout(False)`` are not included |
| 4691 | in the bbox. |
| 4692 | |
| 4693 | Parameters |
| 4694 | ---------- |
| 4695 | renderer : `.RendererBase` subclass |
| 4696 | renderer that will be used to draw the figures (i.e. |
| 4697 | ``fig.canvas.get_renderer()``) |
| 4698 | |
| 4699 | bbox_extra_artists : list of `.Artist` or ``None`` |
| 4700 | List of artists to include in the tight bounding box. If |
| 4701 | ``None`` (default), then all artist children of the Axes are |
| 4702 | included in the tight bounding box. |
| 4703 | |
| 4704 | call_axes_locator : bool, default: True |
| 4705 | If *call_axes_locator* is ``False``, it does not call the |
| 4706 | ``_axes_locator`` attribute, which is necessary to get the correct |
| 4707 | bounding box. ``call_axes_locator=False`` can be used if the |
| 4708 | caller is only interested in the relative size of the tightbbox |
| 4709 | compared to the Axes bbox. |
| 4710 | |
| 4711 | for_layout_only : default: False |
| 4712 | The bounding box will *not* include the x-extent of the title and |
| 4713 | the xlabel, or the y-extent of the ylabel. |
| 4714 | |
| 4715 | Returns |
| 4716 | ------- |
| 4717 | `.BboxBase` |
| 4718 | Bounding box in figure pixel coordinates. |
| 4719 | |
| 4720 | See Also |
| 4721 | -------- |
| 4722 | matplotlib.axes.Axes.get_window_extent |
| 4723 | matplotlib.axis.Axis.get_tightbbox |
| 4724 | matplotlib.spines.Spine.get_window_extent |
| 4725 | """ |
| 4726 | |
| 4727 | bb = [] |
| 4728 | if renderer is None: |
| 4729 | renderer = self.get_figure(root=True)._get_renderer() |
| 4730 | |
| 4731 | if not self.get_visible(): |
| 4732 | return None |
| 4733 | |
| 4734 | locator = self.get_axes_locator() |
| 4735 | self.apply_aspect( |
| 4736 | locator(self, renderer) if locator and call_axes_locator else None) |
| 4737 | |
| 4738 | for axis in self._axis_map.values(): |
| 4739 | if self.axison and axis.get_visible(): |
| 4740 | ba = martist._get_tightbbox_for_layout_only(axis, renderer) |
| 4741 | if ba: |