@@ -1460,19 +1460,10 @@ def _get_xy_transform(self, renderer, s):
1460
1460
1461
1461
def _get_ref_xy (self , renderer ):
1462
1462
"""
1463
- Return x, y (in display coordinate ) that is to be used for a reference
1463
+ Return x, y (in display coordinates ) that is to be used for a reference
1464
1464
of any offset coordinate.
1465
1465
"""
1466
- def is_offset (s ):
1467
- return isinstance (s , str ) and s .split ()[0 ] == "offset"
1468
-
1469
- if isinstance (self .xycoords , tuple ):
1470
- if any (map (is_offset , self .xycoords )):
1471
- raise ValueError ("xycoords should not be an offset coordinate" )
1472
- elif is_offset (self .xycoords ):
1473
- raise ValueError ("xycoords should not be an offset coordinate" )
1474
- x , y = self .xy
1475
- return self ._get_xy (renderer , x , y , self .xycoords )
1466
+ return self ._get_xy (renderer , * self .xy , self .xycoords )
1476
1467
1477
1468
# def _get_bbox(self, renderer):
1478
1469
# if hasattr(bbox, "bounds"):
@@ -1795,10 +1786,24 @@ def contains(self, event):
1795
1786
contains = contains or in_patch
1796
1787
return contains , tinfo
1797
1788
1789
+ @property
1790
+ def xycoords (self ):
1791
+ return self ._xycoords
1792
+
1793
+ @xycoords .setter
1794
+ def xycoords (self , xycoords ):
1795
+ def is_offset (s ):
1796
+ return isinstance (s , str ) and s .startswith ("offset" )
1797
+
1798
+ if (isinstance (xycoords , tuple ) and any (map (is_offset , xycoords ))
1799
+ or is_offset (xycoords )):
1800
+ raise ValueError ("xycoords cannot be an offset coordinate" )
1801
+ self ._xycoords = xycoords
1802
+
1798
1803
@property
1799
1804
def xyann (self ):
1800
1805
"""
1801
- The the text position.
1806
+ The text position.
1802
1807
1803
1808
See also *xytext* in `.Annotation`.
1804
1809
"""
@@ -1808,28 +1813,24 @@ def xyann(self):
1808
1813
def xyann (self , xytext ):
1809
1814
self .set_position (xytext )
1810
1815
1811
- @property
1812
- def anncoords (self ):
1813
- """The coordinate system to use for `.Annotation.xyann`."""
1814
- return self ._textcoords
1815
-
1816
- @anncoords .setter
1817
- def anncoords (self , coords ):
1818
- self ._textcoords = coords
1816
+ def get_anncoords (self ):
1817
+ """
1818
+ Return the coordinate system to use for `.Annotation.xyann`.
1819
1819
1820
- get_anncoords = anncoords . fget
1821
- get_anncoords . __doc__ = """
1822
- Return the coordinate system to use for `.Annotation.xyann`.
1820
+ See also *xycoords* in `.Annotation`.
1821
+ """
1822
+ return self . _textcoords
1823
1823
1824
- See also *xycoords* in `.Annotation`.
1825
- """
1824
+ def set_anncoords (self , coords ):
1825
+ """
1826
+ Set the coordinate system to use for `.Annotation.xyann`.
1826
1827
1827
- set_anncoords = anncoords . fset
1828
- set_anncoords . __doc__ = """
1829
- Set the coordinate system to use for `.Annotation.xyann`.
1828
+ See also *xycoords* in `.Annotation`.
1829
+ """
1830
+ self . _textcoords = coords
1830
1831
1831
- See also *xycoords* in `.Annotation`.
1832
- """
1832
+ anncoords = property ( get_anncoords , set_anncoords , doc = """
1833
+ The coordinate system to use for `.Annotation.xyann`. """ )
1833
1834
1834
1835
def set_figure (self , fig ):
1835
1836
# docstring inherited
0 commit comments