-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Interactive matplotlib charts #72
Comments
Thanks for the suggestion. It's not currently possible, but it's certainly in the realm of the possible. Toga's Canvas element (which is what Chart is built on) has handlers to capture mouse clicks and movements; presumably there is some interface that can be be implemented in a matplotlib backend that will convert canvas-level mouse clicks into the relevant Matplotlib commands. I don't have any immediate plans to work on this, but if you're interested, I'd encourage you to take a look yourself. Although it might seem daunting, the code for toga-chart is a relatively straightforward mapping from Matplotlib's backend API to Toga's Canvas API. It is implemented as a matplotlib backend, the core of which is a subclass of matplotlib.backend_bases.RendererBase. From a quick look at the docs, there is a button_press_handler that is likely at the core of how interactive charts work. You might be able to learn more by poking around the source code for one of the existing interactive backends (Tk, GTK or Qt). |
Hi there, thanks for the information and resources! I think I will take a peak at the matplotlib backend and at how Tk handles that integration. I doubt I'll make much progress, but if I do, I'll get in touch about contributing via a PR. |
@kaylai did you get anywhere with this? 🙏🏻 |
Unfortunately no 😔 |
What is the problem or limitation you are having?
It would be great to have intractability within a toga_chart.Chart() object. I understand Chart() is calling matplotlib. Does that mean any matplotlib styling/functionality can be used within a Chart() object? Currently, a Chart() is plotted as a static thing. I'd like to enable the standard matplotlib controls (pan, zoom, save) and also add a DraggableLine element. Is intractability currently possible, or will this feature be added?
Describe the solution you'd like
If this is not already possible given Chart() is using matplotlib, I would love to see this added as a feature and/or have someway to call any matplotlib stuff (e.g., pyplot.ion).
Describe alternatives you've considered
I tried just calling
pyplot.ion
, but that does not enable intractability.Additional context
No response
The text was updated successfully, but these errors were encountered: