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

Method _findoffset

lib/matplotlib/legend.py:748–763  ·  view source on GitHub ↗

Helper function to locate the legend.

(self, width, height, xdescent, ydescent, renderer)

Source from the content-addressed store, hash-verified

746 _loc = property(_get_loc, _set_loc)
747
748 def _findoffset(self, width, height, xdescent, ydescent, renderer):
749 """Helper function to locate the legend."""
750
751 if self._loc == 0: # "best".
752 x, y = self._find_best_position(width, height, renderer)
753 elif self._loc in Legend.codes.values(): # Fixed location.
754 bbox = Bbox.from_bounds(0, 0, width, height)
755 x, y = self._get_anchored_bbox(self._loc, bbox,
756 self.get_bbox_to_anchor(),
757 renderer)
758 else: # Axes or figure coordinates.
759 fx, fy = self._loc
760 bbox = self.get_bbox_to_anchor()
761 x, y = bbox.x0 + bbox.width * fx, bbox.y0 + bbox.height * fy
762
763 return x + xdescent, y + ydescent
764
765 @allow_rasterization
766 def draw(self, renderer):

Callers

nothing calls this directly

Calls 5

_find_best_positionMethod · 0.95
_get_anchored_bboxMethod · 0.95
get_bbox_to_anchorMethod · 0.95
valuesMethod · 0.80
from_boundsMethod · 0.80

Tested by

no test coverage detected