@@ -1906,32 +1906,30 @@ def update_positions(self, renderer):
19061906 """
19071907 Update the pixel positions of the annotation text and the arrow patch.
19081908 """
1909- x1, y1 = self._get_position_xy(renderer) # Annotated position.
1910- # generate transformation,
1909+ # generate transformation
19111910 self.set_transform(self._get_xy_transform(renderer, self.anncoords))
19121911
1913- if self.arrowprops is None:
1912+ arrowprops = self.arrowprops
1913+ if arrowprops is None:
19141914 return
19151915
19161916 bbox = Text.get_window_extent(self, renderer)
19171917
1918- d = self.arrowprops.copy()
1919- ms = d.pop("mutation_scale", self.get_size())
1918+ arrow_end = x1, y1 = self._get_position_xy(renderer) # Annotated pos.
1919+
1920+ ms = arrowprops.get("mutation_scale", self.get_size())
19201921 self.arrow_patch.set_mutation_scale(ms)
19211922
1922- if "arrowstyle" not in d :
1923+ if "arrowstyle" not in arrowprops :
19231924 # Approximately simulate the YAArrow.
1924- # Pop its kwargs:
1925- shrink = d.pop('shrink', 0.0)
1926- width = d.pop('width', 4)
1927- headwidth = d.pop('headwidth', 12)
1928- # Ignore frac--it is useless.
1929- frac = d.pop('frac', None)
1930- if frac is not None:
1925+ shrink = arrowprops.get('shrink', 0.0)
1926+ width = arrowprops.get('width', 4)
1927+ headwidth = arrowprops.get('headwidth', 12)
1928+ if 'frac' in arrowprops:
19311929 _api.warn_external(
19321930 "'frac' option in 'arrowprops' is no longer supported;"
19331931 " use 'headlength' to set the head length in points.")
1934- headlength = d.pop ('headlength', 12)
1932+ headlength = arrowprops.get ('headlength', 12)
19351933
19361934 # NB: ms is in pts
19371935 stylekw = dict(head_length=headlength / ms,
@@ -1953,29 +1951,25 @@ def update_positions(self, renderer):
19531951
19541952 # adjust the starting point of the arrow relative to the textbox.
19551953 # TODO : Rotation needs to be accounted.
1956- relposx, relposy = self._arrow_relpos
1957- x0 = bbox.x0 + bbox.width * relposx
1958- y0 = bbox.y0 + bbox.height * relposy
1959-
1960- # The arrow will be drawn from (x0, y0) to (x1, y1). It will be first
1954+ arrow_begin = bbox.p0 + bbox.size * self._arrow_relpos
1955+ # The arrow is drawn from arrow_begin to arrow_end. It will be first
19611956 # clipped by patchA and patchB. Then it will be shrunk by shrinkA and
1962- # shrinkB (in points). If patch A is not set, self.bbox_patch is used.
1963- self.arrow_patch.set_positions((x0, y0), (x1, y1))
1964-
1965- if "patchA" in d:
1966- self.arrow_patch.set_patchA(d.pop("patchA"))
1957+ # shrinkB (in points). If patchA is not set, self.bbox_patch is used.
1958+ self.arrow_patch.set_positions(arrow_begin, arrow_end)
1959+
1960+ if "patchA" in arrowprops:
1961+ patchA = arrowprops["patchA"]
1962+ elif self._bbox_patch:
1963+ patchA = self._bbox_patch
1964+ elif self.get_text() == "":
1965+ patchA = None
19671966 else:
1968- if self._bbox_patch:
1969- self.arrow_patch.set_patchA(self._bbox_patch)
1970- else:
1971- if self.get_text() == "":
1972- self.arrow_patch.set_patchA(None)
1973- return
1974- pad = renderer.points_to_pixels(4)
1975- r = Rectangle(xy=(bbox.x0 - pad / 2, bbox.y0 - pad / 2),
1976- width=bbox.width + pad, height=bbox.height + pad,
1977- transform=IdentityTransform(), clip_on=False)
1978- self.arrow_patch.set_patchA(r)
1967+ pad = renderer.points_to_pixels(4)
1968+ patchA = Rectangle(
1969+ xy=(bbox.x0 - pad / 2, bbox.y0 - pad / 2),
1970+ width=bbox.width + pad, height=bbox.height + pad,
1971+ transform=IdentityTransform(), clip_on=False)
1972+ self.arrow_patch.set_patchA(patchA)
19791973
19801974 @artist.allow_rasterization
19811975 def draw(self, renderer):
0 commit comments