MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / get_tightbbox

Method get_tightbbox

lib/mpl_toolkits/mplot3d/axis3d.py:683–729  ·  view source on GitHub ↗
(self, renderer=None, *, for_layout_only=False)

Source from the content-addressed store, hash-verified

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)(

Calls 13

get_majorticklocsMethod · 0.95
get_minorticklocsMethod · 0.95
get_minor_ticksMethod · 0.95
get_major_ticksMethod · 0.95
get_view_intervalMethod · 0.95
get_transformMethod · 0.95
_get_ticklabel_bboxesMethod · 0.95
get_locMethod · 0.80
unionMethod · 0.80
get_visibleMethod · 0.45
transformMethod · 0.45
get_textMethod · 0.45