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

Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,25 +1486,30 @@ def on_motion(self, evt):
self.canvas.draw()

def on_pick(self, evt):
if self._check_still_parented() and evt.artist == self.ref_artist:
self.mouse_x = evt.mouseevent.x
self.mouse_y = evt.mouseevent.y
self.got_artist = True
if self._use_blit:
if self._check_still_parented():
if evt.artist == self.ref_artist:
self.mouse_x = evt.mouseevent.x
self.mouse_y = evt.mouseevent.y
self.save_offset()
self.got_artist = True
if self.got_artist and self._use_blit:
self.ref_artist.set_animated(True)
self.canvas.draw()
self.background = \
self.canvas.copy_from_bbox(self.ref_artist.figure.bbox)
self.ref_artist.draw(
self.ref_artist.figure._get_renderer())
self.canvas.blit()
self.save_offset()

def on_release(self, event):
if self._check_still_parented() and self.got_artist:
self.finalize_offset()
self.got_artist = False
if self._use_blit:
self.canvas.restore_region(self.background)
self.ref_artist.draw(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to restore the background as well here or you will double-draw the legend (set it to have a colored and fraction alpha background to see the effect).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah that's right, added the restoration!

self.ref_artist.figure._get_renderer())
self.canvas.blit()
self.ref_artist.set_animated(False)

def _check_still_parented(self):
Expand Down