Visualizing large time series with plotly
Project description
plotly_resampler
: visualize large sequential data by adding resampling functionality to Plotly figures
Plotly is an awesome interactive visualization library, however it can get pretty slow when a lot of data points are visualized (100 000+ datapoints). This library solves this by downsampling the data respective to the view and then plotting the downsampled points. When you interact with the plot (panning, zooming, ...), dash callbacks are used to resample and redraw the figures.
In this Plotly-Resampler demo over 110,000,000
data points are visualized!
Installation
pip | pip install plotly-resampler |
---|
Usage
To add dynamic resampling to your plotly Figure, you should;
- wrap the plotly Figure with
FigureResampler
- call
.show_dash()
on the Figure
Note:
Any plotly Figure can be wrapped with FigureResampler! 🎉
But, (obviously) only the scatter traces will be resampled.
Tip 💡:
For significant faster initial loading of the Figure, we advise to wrap the constructor of the plotly Figure withFigureResampler
and add the trace data ashf_x
andhf_y
Minimal example
import plotly.graph_objects as go; import numpy as np
from plotly_resampler import FigureResampler
x = np.arange(1_000_000)
noisy_sin = (3 + np.sin(x / 200) + np.random.randn(len(x)) / 10) * x / 1_000
fig = FigureResampler(go.Figure())
fig.add_trace(go.Scattergl(name='noisy sine', showlegend=True), hf_x=x, hf_y=noisy_sin)
fig.show_dash(mode='inline')
Features
- Convenient to use:
- just add the
FigureResampler
decorator around a plotly Figure and call.show_dash()
- allows all other plotly figure construction flexibility to be used!
- just add the
- Environment-independent
- can be used in Jupyter, vscode-notebooks, Pycharm-notebooks, Google Colab, and even as application (on a server)
- Interface for various downsampling algorithms:
- ability to define your preferred sequence aggregation method
Important considerations & tips
- When running the code on a server, you should forward the port of the
FigureResampler.show_dash()
method to your local machine. - In general, when using downsampling one should be aware of (possible) aliasing effects.
The [R] in the legend indicates when the corresponding trace is being resampled (and thus possibly distorted) or not.
Future work 🔨
- Support
.add_traces()
(currently only.add_trace
is supported)
👤 Jonas Van Der Donckt, Jeroen Van Der Donckt, Emiel Deprost
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for plotly_resampler-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ddd1a8908ac02d5acc79b83ede3a43855d2dc00cabaf47658a962bcc4cdaadb |
|
MD5 | 753c9783053fcbb964ff9040292094a1 |
|
BLAKE2b-256 | fb8147a80a3502a33ccae3ab8f7f0de601c4c23d2dac9618be4a8382e5529d7b |