Fix Legend.set_draggable() with update="bbox"#25428
Conversation
| self._update_loc(self.get_loc_in_canvas()) | ||
| elif self._update == "bbox": | ||
| self._bbox_to_anchor(self.get_loc_in_canvas()) | ||
| self._update_bbox_to_anchor(self.get_loc_in_canvas()) |
There was a problem hiding this comment.
Does that mean none of this is tested?
There was a problem hiding this comment.
It only gets triggered when dragging a legend, afaik mpl isn't testing any interactivity, is it?
There was a problem hiding this comment.
I think it's possible to test interactivity. However, whoever put the typo in didn't test, or tested the wrong thing, so perhaps add to the PR description whatever test you are using to ensure this is the correct fix?
There was a problem hiding this comment.
It is possible to test the interactive code, but I think that is way too big of an ask to get a 1 line patch in!
There was a problem hiding this comment.
Yes, sorry, I wasn't meaning to ask for that if its hard, but at least some idea how this should be tested manually.
There was a problem hiding this comment.
@daniilS, since you seem to be doing some interactive PRs, you might be interested in taking a look here for how zoom and other interactive things like widgets are tested: https://github.com/matplotlib/matplotlib/blob/b636e9ed82b930ad4bde0b51360855fa79a7b438/lib/matplotlib/tests/test_backend_bases.py#LL142C3-L142C3
There was a problem hiding this comment.
@greglucas good point - I think all my other PRs were visual changes or toolbar behaviour which is hard to test automatically, but I might be able to write a test for dragging legends as the interaction is happening entirely within the axes.
|
Looks like this was broken in 0f7770a (?!) so this is apparently not a well used bit of functionality. |
import matplotlib.pyplot as plt
plt.plot(range(5), label='bob')
leg = plt.legend()
leg.set_draggable(True, update='bbox')
plt.show()is enough (with some dragging) to reproduce. |
tacaswell
left a comment
There was a problem hiding this comment.
manually tested with code in comments.
|
the appeveyor failure is #25416 |
…428-on-v3.7.x Backport PR #25428 on branch v3.7.x (Fix Legend.set_draggable() with update="bbox")
Typo causes
Legend.set_draggable(True, update="bbox")to be broken.