| 1 | diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py |
| 2 | --- a/lib/matplotlib/offsetbox.py |
| 3 | +++ b/lib/matplotlib/offsetbox.py |
| 4 | @@ -1505,7 +1505,6 @@ def __init__(self, ref_artist, use_blit=False): |
| 5 | if not ref_artist.pickable(): |
| 6 | ref_artist.set_picker(True) |
| 7 | self.got_artist = False |
| 8 | - self.canvas = self.ref_artist.figure.canvas |
| 9 | self._use_blit = use_blit and self.canvas.supports_blit |
| 10 | self.cids = [ |
| 11 | self.canvas.callbacks._connect_picklable( |
| 12 | @@ -1514,6 +1513,9 @@ def __init__(self, ref_artist, use_blit=False): |
| 13 | 'button_release_event', self.on_release), |
| 14 | ] |
| 15 | |
| 16 | + # A property, not an attribute, to maintain picklability. |
| 17 | + canvas = property(lambda self: self.ref_artist.figure.canvas) |
| 18 | + |
| 19 | def on_motion(self, evt): |
| 20 | if self._check_still_parented() and self.got_artist: |
| 21 | dx = evt.x - self.mouse_x |