| 681 | # TODO: Get this to work (more) properly when mplot3d supports the |
| 682 | # transforms framework. |
| 683 | def get_tightbbox(self, renderer=None, *, for_layout_only=False): |
| 684 | # docstring inherited |
| 685 | if not self.get_visible(): |
| 686 | return |
| 687 | # We have to directly access the internal data structures |
| 688 | # (and hope they are up to date) because at draw time we |
| 689 | # shift the ticks and their labels around in (x, y) space |
| 690 | # based on the projection, the current view port, and their |
| 691 | # position in 3D space. If we extend the transforms framework |
| 692 | # into 3D we would not need to do this different book keeping |
| 693 | # than we do in the normal axis |
| 694 | major_locs = self.get_majorticklocs() |
| 695 | minor_locs = self.get_minorticklocs() |
| 696 | |
| 697 | ticks = [*self.get_minor_ticks(len(minor_locs)), |
| 698 | *self.get_major_ticks(len(major_locs))] |
| 699 | view_low, view_high = self.get_view_interval() |
| 700 | if view_low > view_high: |
| 701 | view_low, view_high = view_high, view_low |
| 702 | interval_t = self.get_transform().transform([view_low, view_high]) |
| 703 | |
| 704 | ticks_to_draw = [] |
| 705 | for tick in ticks: |
| 706 | try: |
| 707 | loc_t = self.get_transform().transform(tick.get_loc()) |
| 708 | except AssertionError: |
| 709 | # Transform.transform doesn't allow masked values but |
| 710 | # some scales might make them, so we need this try/except. |
| 711 | pass |
| 712 | else: |
| 713 | if mtransforms._interval_contains_close(interval_t, loc_t): |
| 714 | ticks_to_draw.append(tick) |
| 715 | |
| 716 | ticks = ticks_to_draw |
| 717 | |
| 718 | bb_1, bb_2 = self._get_ticklabel_bboxes(ticks, renderer) |
| 719 | other = [] |
| 720 | |
| 721 | if self.offsetText.get_visible() and self.offsetText.get_text(): |
| 722 | other.append(self.offsetText.get_window_extent(renderer)) |
| 723 | if self.line.get_visible(): |
| 724 | other.append(self.line.get_window_extent(renderer)) |
| 725 | if (self.label.get_visible() and not for_layout_only and |
| 726 | self.label.get_text()): |
| 727 | other.append(self.label.get_window_extent(renderer)) |
| 728 | |
| 729 | return mtransforms.Bbox.union([*bb_1, *bb_2, *other]) |
| 730 | |
| 731 | d_interval = _api.deprecated( |
| 732 | "3.6", alternative="get_data_interval", pending=True)( |