💫 Plotly-resampler - Visualize large time series using plotly-dash

I proudly present plotly-resampler, a wrapper around the plotly Figure object, which is able to visualize large sequences of time-series data.

basic_example

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
14 Likes

This is SO cool! I can’t wait to try it out :smiley:

1 Like

This is impressive work :fire: Thank you for building this and sharing with the community, @jonvdrdo .

1 Like

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

1 Like

Hi @Wabiloo!

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! :slight_smile:

1 Like

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?

1 Like

Hi @ggreen,

Thank you for your kind words, means a lot! :heavy_heart_exclamation:
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!

Cheers,
Jonas

1 Like

Hi @jonvdrdo,

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 :slight_smile:

Best,
Gabe

Brilliant! Can’t wait to try it out on my project!

1 Like

This looks really amazing. I tried to give it a go and ran into some stumbling blocks mentioned here [PLOTLY RESAMPLE] What can I do to choose how much plotly resample samples?. This looks like exactly the right solution to my problem because I’m trying to visualize lots and lots of data.

1 Like

Hi,

Why do I get this Warning

C:\Pycharm_Project\Plotly\lib\site-packages\plotly_resampler\aggregation\aggregators.py:24: UserWarning:

Could not import lttbc; will use a (slower) python alternative.

Any help will be useful. I am running with this warning and things does not look bad.

Hi @Akshay91 ,

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.

Hope this answers your question.

Kind regards,
Jonas

1 Like

Hi @jonvdrdo,

Thanks for your revert. I did re-install plotly-resampler and found nothing strange in the output. Other than installed successfully.

What should I do next?

I don’t mind the speed until the file size is <200 MB. More than that, I can see lag in interactivity.

Hi @Akshay91,

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!

Kind regards,
Jonas

A post was split to a new topic: Tool to create GIFs

Hi @jonvdrdo ,

My apologies for replying to you after 7 months. I got side-tracked and had to park this project. Coming back to your support questions.

  • I am using Windows 10 and I install the package using Pycharm interpreter

  • 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
    image

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.

Warm Regards

Hi @Akshay91,

During those 7 months, we updated the aggregation backend from this to-be-compiled C-code to precompiled rust binaries.

More information can be found as always in the release notes.

Cheers,
Jonas