8000 Merge pull request #6892 from anntzer/keep-draggable-annotation-annco… · matplotlib/matplotlib@06feaf6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 06feaf6

Browse files
committed
Merge pull request #6892 from anntzer/keep-draggable-annotation-anncoords
FIX: Don't force anncoords to fig coords upon dragging.
1 parent 5fb9017 commit 06feaf6

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,30 +1744,12 @@ def __init__(self, annotation, use_blit=False):
17441744

17451745
def save_offset(self):
17461746
ann = self.annotation
1747-
x, y = ann.xyann
1748-
if isinstance(ann.anncoords, tuple):
1749-
xcoord, ycoord = ann.anncoords
1750-
x1, y1 = ann._get_xy(self.canvas.renderer, x, y, xcoord)
1751-
x2, y2 = ann._get_xy(self.canvas.renderer, x, y, ycoord)
1752-
ox0, oy0 = x1, y2
1753-
else:
1754-
ox0, oy0 = ann._get_xy(self.canvas.renderer, x, y, ann.anncoords)
1755-
1756-
self.ox, self.oy = ox0, oy0
1757-
self.annotation.anncoords = "figure pixels"
1758-
self.update_offset(0, 0)
1747+
self.ox, self.oy = ann.get_transform().transform(ann.xyann)
17591748

17601749
def update_offset(self, dx, dy):
17611750
ann = self.annotation
1762-
ann.xyann = self.ox + dx, self.oy + dy
1763-
x, y = ann.xyann
1764-
1765-
def finalize_offset(self):
1766-
loc_in_canvas = self.annotation.xyann
1767-
self.annotation.anncoords = "axes fraction"
1768-
pos_axes_fraction = self.annotation.axes.transAxes.inverted()
1769-
pos_axes_fraction = pos_axes_fraction.transform_point(loc_in_canvas)
1770-
self.annotation.xyann = tuple(pos_axes_fraction)
1751+
ann.xyann = ann.get_transform().inverted().transform(
1752+
(self.ox + dx, self.oy + dy))
17711753

17721754

17731755
if __name__ == "__main__":

0 commit comments

Comments
 (0)
0