@@ -1906,32 +1906,30 @@ def update_positions(self, renderer):
1906
1906
"""
1907
1907
Update the pixel positions of the annotation text and the arrow patch.
1908
1908
"""
1909
- x1 , y1 = self ._get_position_xy (renderer ) # Annotated position.
1910
- # generate transformation,
1909
+ # generate transformation
1911
1910
self .set_transform (self ._get_xy_transform (renderer , self .anncoords ))
1912
1911
1913
- if self .arrowprops is None :
1912
+ arrowprops = self .arrowprops
1913
+ if arrowprops is None :
1914
1914
return
1915
1915
1916
1916
bbox = Text .get_window_extent (self , renderer )
1917
1917
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 ())
1920
1921
self .arrow_patch .set_mutation_scale (ms )
1921
1922
1922
- if "arrowstyle" not in d :
1923
+ if "arrowstyle" not in arrowprops :
1923
1924
# 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 :
1931
1929
_api .warn_external (
1932
1930
"'frac' option in 'arrowprops' is no longer supported;"
1933
1931
" use 'headlength' to set the head length in points." )
1934
- headlength = d . pop ('headlength' , 12 )
1932
+ headlength = arrowprops . get ('headlength' , 12 )
1935
1933
1936
1934
# NB: ms is in pts
1937
1935
stylekw = dict (head_length = headlength / ms ,
@@ -1953,29 +1951,25 @@ def update_positions(self, renderer):
1953
1951
1954
1952
# adjust the starting point of the arrow relative to the textbox.
1955
1953
# 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
1961
1956
# 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
1967
1966
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 )
1979
1973
1980
1974
@artist .allow_rasterization
1981
1975
def draw (self , renderer ):
0 commit comments