@@ -1265,6 +1265,10 @@ def __init__(self, offsetbox, xy,
12651265
12661266 self .set_fontsize (fontsize )
12671267
1268+ self .xybox = xybox
1269+
1270+ self .boxcoords = boxcoords
1271+
12681272 if arrowprops is not None :
12691273 self ._arrow_relpos = self .arrowprops .pop ("relpos" , (0.5 , 0.5 ))
12701274 self .arrow_patch = FancyArrowPatch ((0 , 0 ), (1 , 1 ),
@@ -1274,8 +1278,8 @@ def __init__(self, offsetbox, xy,
12741278 self .arrow_patch = None
12751279
12761280 _AnnotationBase .__init__ (self ,
1277- xy , xytext = xybox ,
1278- xycoords = xycoords , textcoords = boxcoords ,
1281+ xy ,
1282+ xycoords = xycoords ,
12791283 annotation_clip = annotation_clip )
12801284
12811285 martist .Artist .__init__ (self , ** kwargs )
@@ -1295,6 +1299,22 @@ def __init__(self, offsetbox, xy,
12951299 self .patch .set (** bboxprops )
12961300 self ._drawFrame = frameon
12971301
1302+ @property
1303+ def xyann (self ):
1304+ return self .xybox
1305+
1306+ @xyann .setter
1307+ def xyann (self , xyann ):
1308+ self .xybox = xyann
1309+
1310+ @property
1311+ def anncoords (self ):
1312+ return self .boxcoords
1313+
1314+ @anncoords .setter
1315+ def anncoords (self , coords ):
1316+ self .boxcoords = coords
1317+
12981318 def contains (self , event ):
12991319 t , tinfo = self .offsetbox .contains (event )
13001320 #if self.arrow_patch is not None:
@@ -1352,14 +1372,14 @@ def _update_position_xybox(self, renderer, xy_pixel):
13521372 patch.
13531373 """
13541374
1355- x , y = self .xytext
1356- if isinstance (self .textcoords , tuple ):
1357- xcoord , ycoord = self .textcoords
1375+ x , y = self .xybox
1376+ if isinstance (self .boxcoords , tuple ):
1377+ xcoord , ycoord = self .boxcoords
13581378 x1 , y1 = self ._get_xy (renderer , x , y , xcoord )
13591379 x2 , y2 = self ._get_xy (renderer , x , y , ycoord )
13601380 ox0 , oy0 = x1 , y2
13611381 else :
1362- ox0 , oy0 = self ._get_xy (renderer , x , y , self .textcoords )
1382+ ox0 , oy0 = self ._get_xy (renderer , x , y , self .boxcoords )
13631383
13641384 w , h , xd , yd = self .offsetbox .get_extent (renderer )
13651385
@@ -1579,32 +1599,30 @@ def __init__(self, annotation, use_blit=False):
15791599
15801600 def save_offset (self ):
15811601 ann = self .annotation
1582- x , y = ann .xytext
1583- if isinstance (ann .textcoords , tuple ):
1584- xcoord , ycoord = ann .textcoords
1602+ x , y = ann .xyann
1603+ if isinstance (ann .anncoords , tuple ):
1604+ xcoord , ycoord = ann .anncoords
15851605 x1 , y1 = ann ._get_xy (self .canvas .renderer , x , y , xcoord )
15861606 x2 , y2 = ann ._get_xy (self .canvas .renderer , x , y , ycoord )
15871607 ox0 , oy0 = x1 , y2
15881608 else :
1589- ox0 , oy0 = ann ._get_xy (self .canvas .renderer , x , y , ann .textcoords )
1609+ ox0 , oy0 = ann ._get_xy (self .canvas .renderer , x , y , ann .anncoords )
15901610
15911611 self .ox , self .oy = ox0 , oy0
1592- self .annotation .textcoords = "figure pixels"
1612+ self .annotation .anncoords = "figure pixels"
15931613 self .update_offset (0 , 0 )
15941614
15951615 def update_offset (self , dx , dy ):
15961616 ann = self .annotation
1597- ann .xytext = self .ox + dx , self .oy + dy
1598- x , y = ann .xytext
1599- # xy is never used
1600- xy = ann ._get_xy (self .canvas .renderer , x , y , ann .textcoords )
1617+ ann .xyann = self .ox + dx , self .oy + dy
1618+ x , y = ann .xyann
16011619
16021620 def finalize_offset (self ):
1603- loc_in_canvas = self .annotation .xytext
1604- self .annotation .textcoords = "axes fraction"
1621+ loc_in_canvas = self .annotation .xyann
1622+ self .annotation .anncoords = "axes fraction"
16051623 pos_axes_fraction = self .annotation .axes .transAxes .inverted ()
16061624 pos_axes_fraction = pos_axes_fraction .transform_point (loc_in_canvas )
1607- self .annotation .xytext = tuple (pos_axes_fraction )
1625+ self .annotation .xyann = tuple (pos_axes_fraction )
16081626
16091627
16101628if __name__ == "__main__" :
0 commit comments