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

Skip to content

Commit c77e9d5

Browse files
committed
Move picker to method
1 parent 29e7d8d commit c77e9d5

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,15 +1486,7 @@ def finalize_offset(self):
14861486
def __init__(self, ref_artist, use_blit=False):
14871487
self.ref_artist = ref_artist
14881488
if not ref_artist.pickable():
1489-
ref_artist.set_picker(
1490-
lambda artist, mouseevent: (
1491-
(
1492-
artist.contains(mouseevent) and
1493-
mouseevent.name != "scroll_event"
1494-
),
1495-
{}
1496-
)
1497-
)
1489+
ref_artist.set_picker(self._picker)
14981490
self.got_artist = False
14991491
self._use_blit = use_blit and self.canvas.supports_blit
15001492
callbacks = self.canvas.callbacks
@@ -1508,6 +1500,10 @@ def __init__(self, ref_artist, use_blit=False):
15081500
]
15091501
]
15101502

1503+
@staticmethod
1504+
def _picker(artist, mouseevent):
1505+
return (artist.contains(mouseevent) and mouseevent.name != "scroll_event"), {}
1506+
15111507
# A property, not an attribute, to maintain picklability.
15121508
canvas = property(lambda self: self.ref_artist.get_figure(root=True).canvas)
15131509
cids = property(lambda self: [

0 commit comments

Comments
 (0)