Draft PR: On adding data tooltip support (#23378) #30133
+280
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello there,
This pull request introduces basic native tooltip support in Matplotlib, addressing issue #23378. The goal is to enable tooltips that display arbitrary user-defined data, and not just coordinates, when hovering over data points.
I’m new to contributing to the Matplotlib open-source project, and with this implementation, I’ve done my best to follow the development guidelines. I welcome any feedback for improvement. I have also reviewed the previous pull request #25831, which was rejected, and I want to ensure my current approach aligns better with Matplotlib’s goals. At this stage, I would greatly appreciate feedback on whether I’m heading in the right direction.
The following components are currently working:
High-level API support:
plt.plot(x, y, tooltip=['A', 'B', 'C']) now accepts the tooltip argument. Tooltip data is correctly extracted from kwargs in axes.py.
Data storage system:
Artists support set_tooltip() and get_tooltip().
Tooltips support:
Strings (e.g. "Data point")
Lists (e.g. ['A', 'B', 'C'])
Functions (e.g. lambda x, y: f'({x}, {y})')
Basic infrastructure:
Canvas includes show_tooltip() and hide_tooltip()
Figure implements _on_mouse_move_for_tooltip() to handle mouse movement
Local installation works using pip install -e .
I have tested the following so far:
Tooltip data is being stored correctly:


My backend supports tooltip-related data functions:
What I currently need help with is mouse event detection. At the moment, hovering over data points does not trigger the tooltip display. Since adding this feature touches many parts of the codebase, I am unsure how to properly integrate this with Matplotlib’s existing event-handling system. Any guidance or suggestions would be greatly appreciated.