MCPcopy
hub / github.com/matplotlib/matplotlib / _update_label_position

Method _update_label_position

lib/matplotlib/axis.py:2832–2856  ·  view source on GitHub ↗

Update the label position based on the bounding box enclosing all the ticklabels and axis spine

(self, renderer)

Source from the content-addressed store, hash-verified

2830 self.stale = True
2831
2832 def _update_label_position(self, renderer):
2833 """
2834 Update the label position based on the bounding box enclosing
2835 all the ticklabels and axis spine
2836 """
2837 if not self._autolabelpos:
2838 return
2839
2840 # get bounding boxes for this axis and any siblings
2841 # that have been set by `fig.align_ylabels()`
2842 bboxes, bboxes2 = self._get_tick_boxes_siblings(renderer=renderer)
2843 x, y = self.label.get_position()
2844
2845 if self.label_position == 'left':
2846 # Union with extents of the left spine if present, of the axes otherwise.
2847 bbox = mtransforms.Bbox.union([
2848 *bboxes, self.axes.spines.get("left", self.axes).get_window_extent()])
2849 self.label.set_position(
2850 (bbox.x0 - self.labelpad * self.get_figure(root=True).dpi / 72, y))
2851 else:
2852 # Union with extents of the right spine if present, of the axes otherwise.
2853 bbox = mtransforms.Bbox.union([
2854 *bboxes2, self.axes.spines.get("right", self.axes).get_window_extent()])
2855 self.label.set_position(
2856 (bbox.x1 + self.labelpad * self.get_figure(root=True).dpi / 72, y))
2857
2858 def _update_offset_text_position(self, bboxes, bboxes2):
2859 """

Callers

nothing calls this directly

Calls 7

unionMethod · 0.80
get_positionMethod · 0.45
get_window_extentMethod · 0.45
getMethod · 0.45
set_positionMethod · 0.45
get_figureMethod · 0.45

Tested by

no test coverage detected