Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6856ea5

Browse files
committed
Fix Annotation using different units and different coords on x/y.
`_get_xy` always needs to be called with self.xycoord, not just the coordinate system of either x or y, so that unitful x/y get correctly converted as needed.
1 parent cf6c569 commit 6856ea5

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/matplotlib/text.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,19 +1864,12 @@ def is_offset(s):
18641864
return isinstance(s, str) and s.split()[0] == "offset"
18651865

18661866
if isinstance(self.xycoords, tuple):
1867-
s1, s2 = self.xycoords
1868-
if is_offset(s1) or is_offset(s2):
1867+
if any(map(is_offset, self.xycoords)):
18691868
raise ValueError("xycoords should not be an offset coordinate")
1870-
x, y = self.xy
1871-
x1, y1 = self._get_xy(renderer, x, y, s1)
1872-
x2, y2 = self._get_xy(renderer, x, y, s2)
1873-
return x1, y2
18741869
elif is_offset(self.xycoords):
18751870
raise ValueError("xycoords should not be an offset coordinate")
1876-
else:
1877-
x, y = self.xy
1878-
return self._get_xy(renderer, x, y, self.xycoords)
1879-
#raise RuntimeError("must be defined by the derived class")
1871+
x, y = self.xy
1872+
return self._get_xy(renderer, x, y, self.xycoords)
18801873

18811874
# def _get_bbox(self, renderer):
18821875
# if hasattr(bbox, "bounds"):

0 commit comments

Comments
 (0)