-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH]: Data tooltip support #23378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is this different than the existing cursor coord readout? I far prefer a readout in the corner to a data tooltip because it doesn't cover my data more than the mouse already does.... |
This is different because you can show arbitrary data, not just the coordinates. |
My instinct is a How does this interact with the existing |
T.b.d. I think I'm looking for things like this: https://docs.bokeh.org/en/latest/docs/user_guide/tools.html#hovertool in particular also the ability to show context information on data points, which |
How does this differ from how https://mplcursors.readthedocs.io/ and https://github.com/joferkington/mpldatacursor implement hovering/would it make those libraries way simpler? |
This should, btw, also be possible to support in the PDF and SVG backends. |
I think we even have a demo of post-processing an SVG to add tooltips. |
Slightly related: #9957 |
Hi there, Some group members and I are working on implementing tooltip support for this issue, and we're looking for guidance on the most efficient way to handle the high-level API. Rather than modifying each plotting function individually (e.g., plot(), scatter(), bar(), etc.) to accept a hover parameter, is there a preferred approach for applying this functionality across all plotting functions? We’re wondering if there’s: A shared wrapper, internal dispatcher, or base function we could hook into, A decorator pattern that could be reused, Or perhaps an existing mechanism (like how data or label are handled) that we could align with? Our goal is to avoid duplicating logic while ensuring consistent behavior and maintaining backward compatibility. Any suggestions on where best to integrate this or references to similar patterns used in the codebase would be appreciated. Thanks in advance! |
You can and probably should add this to the Artist base class - That said, you don't have to implement all Artists right away. I suggest starting with Line2D. If you manage to to do 1., 2. and a specific version of 3. for Line2D, you've come quite far. We can generalize the high level API subsequently. |
@Dil003 to follow on Tim's comment, you may also want to look at the data cursor mechanism/API folks have been discussing b/c it's got somewhat similar functionality and possibly look at how some of the third party packages implement it. |
Problem
To better support interactivity and contextual data, we should support data tooltips.
Proposed solution
Things to be done:
backend_bases
. This should be similar to the picker functionality, only with hover instead of click. T.b.d.: Do we want aTooltipEvent
or a more generalHoverEvent
?We likely want at least:
plt.plot(x, y, tooltip=['A', 'B', 'C', 'D'])
data
support:plt.plot('x', 'y', tooltip='label', data=data)
plt.plot(x, y, tooltip=lambda x, y: f'({x}, {y})')
The text was updated successfully, but these errors were encountered: