deephaven / deephaven-core

Deephaven Community Core
Other
254 stars 80 forks source link

Allow matplotlib charts to be interactive #2080

Open mofojed opened 2 years ago

mofojed commented 2 years ago

As a matplotlib user, I want to be able to zoom into a plot after I've created it so that I can analyze my data better

mofojed commented 2 years ago

Need to allow for the matplotlib events: https://matplotlib.org/stable/users/explain/event_handling.html Or implement the WebAgg frontend (would require a websocket for each plot). Can then possibly add functions like simple zoom: https://gist.github.com/tacaswell/3144287

mofojed commented 2 years ago
      /* It is up to the application to provide a websocket that the figure
        will use to communicate to the server.  This websocket object can
        also be a "fake" websocket that underneath multiplexes messages
        from multiple figures, if necessary. */

It looks like all we need to implement for the websocket interface is send_json and send_binary: https://github.com/matplotlib/matplotlib/blob/f3a2d413d05283876e78090b403cd47f4b441540/lib/matplotlib/backends/backend_webagg_core.py#L478 https://github.com/matplotlib/matplotlib/blob/ec15c1f3e058751edb44a0dc5d165fa9166b7c03/lib/matplotlib/backends/backend_webagg.py#L149

Could connect that to tables (input tables?), and then use table sockets for communication perhaps?

mofojed commented 2 years ago

Using just the Agg backend doesn't allow animations to work. Event loop for animations isn't firing because the base timer doesn't have a _timer_start event that actually does anything. Other backends define the TimerBase. It gets the event_source in animation.py if none is defined. Could try defining our own event source for animations? Says internal subclasses can override _timer_cls instead of New_timer. So we may need to override new_timer?