def update_positions(self, renderer): x, y = self.xytext self._x, self._y = self._get_xy(x, y, self.textcoords) x, y = self.xy x, y = self._get_xy(x, y, self.xycoords) if self.arrowprops: x0, y0 = x, y l, b, w, h = self.get_window_extent(renderer).get_bounds() dpi = self.figure.dpi.get() r = l + w t = b + h xc = 0.5 * (l + r) yc = 0.5 * (b + t) # pick the x,y corner of the text bbox closest to point # annotated dsu = [(abs(val - x0), val) for val in l, r, xc] dsu.sort() d, x = dsu[0] dsu = [(abs(val - y0), val) for val in b, t, yc] dsu.sort() d, y = dsu[0] d = self.arrowprops.copy() width = d.pop('width', 4) headwidth = d.pop('headwidth', 12) frac = d.pop('frac', 0.1) shrink = d.pop('shrink', 0.0) theta = math.atan2(y - y0, x - x0) r = math.sqrt((y - y0)**2. + (x - x0)**2.) dx = shrink * r * math.cos(theta) dy = shrink * r * math.sin(theta) self.arrow = YAArrow(self.figure.dpi, (x0 + dx, y0 + dy), (x - dx, y - dy), width=width, headwidth=headwidth, frac=frac, **d) self.arrow.set_clip_box(self.get_clip_box())