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

Skip to content

Commit 6f1c68e

Browse files
authored
Merge pull request #7102 from fariza/artist-value-tool-message
ENH: Adding the artist data on mouse move event message
2 parents 15f9581 + 4dc7ff5 commit 6f1c68e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,11 +2886,10 @@ def mouse_move(self, event):
28862886
pass
28872887
else:
28882888
artists = [a for a in event.inaxes.mouseover_set
2889-
if a.contains(event)]
2889+
if a.contains(event) and a.get_visible()]
28902890

28912891
if artists:
2892-
2893-
a = max(enumerate(artists), key=lambda x: x[1].zorder)[1]
2892+
a = max(artists, key=lambda x: x.zorder)
28942893
if a is not event.inaxes.patch:
28952894
data = a.get_cursor_data(event)
28962895
if data is not None:

lib/matplotlib/backend_tools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,16 @@ def send_message(self, event):
335335
except (ValueError, OverflowError):
336336
pass
337337
else:
338+
artists = [a for a in event.inaxes.mouseover_set
339+
if a.contains(event) and a.get_visible()]
340+
341+
if artists:
342+
a = max(artists, key=lambda x: x.zorder)
343+
if a is not event.inaxes.patch:
344+
data = a.get_cursor_data(event)
345+
if data is not None:
346+
s += ' [%s]' % a.format_cursor_data(data)
347+
338348
message = s
339349
self.toolmanager.message_event(message, self)
340350

0 commit comments

Comments
 (0)