Don't force anncoords to fig coords upon dragging. #6892

Merged
merged 1 commit into from Aug 4, 2016

Conversation

Projects
None yet
5 participants
Contributor

anntzer commented Aug 3, 2016

See #6783.

Minimal example:

from matplotlib import pyplot as plt

plt.annotate("foo", (.5, .5),
            (15, 15), textcoords="offset points",
            arrowprops={"arrowstyle": "->"},
            bbox={"ec": "k"}).draggable()
plt.show()

Panning the axes shows that the annotation uses offset coordinates: it moves
"with" the point it points to. However, (before this patch is applied,) after
dragging the annotation somewhere else, it switches to figure coordinates: when
panning the axes, the text box stops physically moving; instead it's the arrow
that moves to follow the point.

The fix actually makes the code simpler...

@anntzer anntzer Don't force anncoords to fig coords upon dragging.
Minimal example:

    from matplotlib import pyplot as plt

    plt.annotate("foo", (.5, .5),
                (15, 15), textcoords="offset points",
                arrowprops={"arrowstyle": "->"},
                bbox={"ec": "k"}).draggable()
    plt.show()

Panning the axes shows that the annotation uses offset coordinates: it moves
"with" the point it points to.  However, (before this patch is applied,) after
dragging the annotation somewhere else, it switches to figure coordinates: when
panning the axes, the text box stops physically moving; instead it's the arrow
that moves to follow the point.

The fix actually makes the code simpler...
37ff0e0

mdboom added the needs_review label Aug 3, 2016

@tacaswell tacaswell commented on the diff Aug 4, 2016

lib/matplotlib/offsetbox.py
def update_offset(self, dx, dy):
ann = self.annotation
- ann.xyann = self.ox + dx, self.oy + dy
- x, y = ann.xyann
-
- def finalize_offset(self):
@tacaswell

tacaswell Aug 4, 2016

Owner

was this just not used?

@tacaswell

tacaswell Aug 4, 2016

Owner

🐑 I should read before commenting more often, this makes it fall back to the no-op baseclass implementation.

tacaswell added this to the 2.1 (next point release) milestone Aug 4, 2016

Owner

tacaswell commented Aug 4, 2016

👍 Awesome when bug fixes remove code!

@tacaswell tacaswell merged commit 0e1c687 into matplotlib:master Aug 4, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.02%) to 70.864%
Details

tacaswell removed the needs_review label Aug 4, 2016

@tacaswell tacaswell added a commit that referenced this pull request Aug 4, 2016

@tacaswell tacaswell Merge pull request #6892 from anntzer/keep-draggable-annotation-annco…
…ords

FIX: Don't force anncoords to fig coords upon dragging.
06feaf6
Owner

tacaswell commented Aug 4, 2016

backported to v2.x as 06feaf6 (you can tell I was on the fence about this my the re-re-re-(..) milestoning.

Member

QuLogic commented Aug 4, 2016

the re-re-re-(..) milestoning

Then why is it 2.0.1 and not 2.0 when it's already backported?

Owner

tacaswell commented Aug 4, 2016

Without really discussing it with anyone I have been using 2.0 -> blocking 2.0.1 -> can be backported, but not blocking.

anntzer deleted the anntzer:keep-draggable-annotation-anncoords branch Aug 4, 2016

Member

QuLogic commented Aug 4, 2016

OK, but that makes things confusing when 2.0.0 is released and stuff on the 2.0.1 milestone needs to be backported. Unless nothing is really supposed to be on the 2.0.1 milestone without a backport?

Also, I've been moving this to 2.0 anyway, so maybe that distinction has been lost a bit already...

Owner

jenshnielsen commented Aug 4, 2016

Everything on the 2.0.1 milestone needs to land on the 2.x branch either via direct merge to 2.x or backport otherwise it can't go into 2.0.1 The only difference as I see it is that 2.0.1 stuff does not need to land before we release 2.0.0

Member

QuLogic commented Aug 4, 2016

Yes, of course, but the question is, when it's already on 2.x, should it be tagged 2.0.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment