I proudly present plotly-resampler, a wrapper around the plotly Figure object, which is able to visualize large sequences of time-series data.
I wrote a custom dash-component to optimize the callbacks (i.e. only send the to-be updated trace data to the client). I am rather sure that this component & the source code can still be improved!
Any feedback/contributions are welcome!
Main features:
Convenient to use:
just add the FigureResampler decorator around a plotly Figure constructor and call .show_dash()
allows all other plotly figure construction flexibility to be used!
Environment-independent
can be used in Jupyter, vscode-notebooks, Pycharm-notebooks, as application (on a server)
Interface for various downsampling algorithms:
ability to define your preferred sequence aggregation method
Could this be used with large amount of data that’s not strictly time-series? In my case I have data about frames in a video, so consecutive indices from 0 to a large number
plotly-resampler supports numeric-indices (i.e., not-time based indices (see the noisy-sine on the right-top subplot of the example gif)) so I suppose it will work!
This is really amazing work! I recently inherited an app the integrates Dash into a Flask app and then generates timeseries figures dynamically that could really benefit from something like this. @jonvdrdo I know you have an example of using this with dynamically generated figures, but do you think it could work with dash running on top of a custom Flask app?
Thank you for your kind words, means a lot!
Regarding the Flask app example; I think this should be possible, and it would also benefit others if we would also incorporate this into the examples folder of the repository.
I would suggest that you create a GitHub issue in which you post a (minimal) working flask example which you would like to have extended with plotly-resampler functionality!
It’s very generous of you to be willing to spend time working on all these examples! I really appreciate it.
The app I inherited is a bit odd compared with other example Flask Dash apps I’ve seen so I’ll try to come up with a minimal example using a more standard approach. Full disclosure I’m very new to the Flask and Dash libraries (and coding in general) so it may take me a bit to get an example ready, but I will do my best.
I’m really new to this community, but its really awesome to see what people like you are doing
This most likely means that our more efficient C-implementation of the LTTB data aggregation algorithm (i.e., lttbc) was not compiled successfully during installation of plotly-resampler.
(I suggest you take a closer look at the output during (re)installation)
As a result, this lttbc cannot be used at runtime, and we will fall back to (our somewhat) slower python implementation. So everything will work just fine, but a little slower.
what platform are you using, how do you install the package?
Can you compile other c-code on your platform (e.g., do you have gcc installed)?
Can you output the install output when you try to install it via pip? (i.e. pip install plotly-resampler==0.8.2)
If you can give me this infromation, I might be able to help you!
Yes, I can compile other C code and have gcc installed on my system.
I have configured my Pycharm to install any python package using pip. I get his output
I like to mention that I updated my plotly-resampler to 0.9.1 and I don’t have issues mentioned in the original post with LTTB package. Previously, I was using 0.8.2 version.
Awesome library. It greatly simplifies the visualization of large datasets.
Is there a way to use these plots with Quarto in an HTML report?
In my initial attempts, I only received a “Loading…” where the graphic should be, instead of the actual plot.
The plot is only visualized in the HTML with fig.show(), which disables the automatic updating feature.
This is an awesome tool, however, it’s feature description is hidden in the source code.
What most users will wonder, how does the aggregation actually happen?
Only in the source code you will find, that the following package is used
Thank you for your kind words and this remark!
Indeed, the data-aggregation functionality is somewhat opaque!
I will make a GitHub issue based on your remark, and try to improve the GitHub readme/docs in the near future.