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

Method update_positions

lib/matplotlib/offsetbox.py:1481–1515  ·  view source on GitHub ↗

Update pixel positions for the annotated point, the text, and the arrow.

(self, renderer)

Source from the content-addressed store, hash-verified

1479 for child in self.get_children()])
1480
1481 def update_positions(self, renderer):
1482 """Update pixel positions for the annotated point, the text, and the arrow."""
1483
1484 ox0, oy0 = self._get_xy(renderer, self.xybox, self.boxcoords)
1485 bbox = self.offsetbox.get_bbox(renderer)
1486 fw, fh = self._box_alignment
1487 self.offsetbox.set_offset(
1488 (ox0 - fw*bbox.width - bbox.x0, oy0 - fh*bbox.height - bbox.y0))
1489
1490 bbox = self.offsetbox.get_window_extent(renderer)
1491 self.patch.set_bounds(bbox.bounds)
1492
1493 mutation_scale = renderer.points_to_pixels(self.get_fontsize())
1494 self.patch.set_mutation_scale(mutation_scale)
1495
1496 if self.arrowprops:
1497 # Use FancyArrowPatch if self.arrowprops has "arrowstyle" key.
1498
1499 # Adjust the starting point of the arrow relative to the textbox.
1500 # TODO: Rotation needs to be accounted.
1501 arrow_begin = bbox.p0 + bbox.size * self._arrow_relpos
1502 arrow_end = self._get_position_xy(renderer)
1503 # The arrow (from arrow_begin to arrow_end) will be first clipped
1504 # by patchA and patchB, then shrunk by shrinkA and shrinkB (in
1505 # points). If patch A is not set, self.bbox_patch is used.
1506 self.arrow_patch.set_positions(arrow_begin, arrow_end)
1507
1508 if "mutation_scale" in self.arrowprops:
1509 mutation_scale = renderer.points_to_pixels(
1510 self.arrowprops["mutation_scale"])
1511 # Else, use fontsize-based mutation_scale defined above.
1512 self.arrow_patch.set_mutation_scale(mutation_scale)
1513
1514 patchA = self.arrowprops.get("patchA", self.patch)
1515 self.arrow_patch.set_patchA(patchA)
1516
1517 def draw(self, renderer):
1518 # docstring inherited

Callers 3

get_window_extentMethod · 0.95
get_tightbboxMethod · 0.95
drawMethod · 0.95

Calls 12

get_fontsizeMethod · 0.95
_get_position_xyMethod · 0.80
set_patchAMethod · 0.80
_get_xyMethod · 0.45
get_bboxMethod · 0.45
set_offsetMethod · 0.45
get_window_extentMethod · 0.45
set_boundsMethod · 0.45
points_to_pixelsMethod · 0.45
set_mutation_scaleMethod · 0.45
set_positionsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected