Skip to main content

Visualizing large time series with plotly

Project description

Plotly-Resampler logo

PyPI Latest Release support-version codecov Code quality PRs Welcome Documentation Testing

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.

example demo

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;

  1. wrap the constructor of your plotly Figure with FigureResampler
  2. call .show_dash() on the Figure

(OPTIONAL) add the trace data as hf_x and hf_y (for faster initial loading)

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 constructor and call .show_dash()
    • allows all other ploty 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

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

plotly-resampler-0.2.7.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plotly_resampler-0.2.7-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file plotly-resampler-0.2.7.tar.gz.

File metadata

  • Download URL: plotly-resampler-0.2.7.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.7.5 Linux/4.15.0-23-generic

File hashes

Hashes for plotly-resampler-0.2.7.tar.gz
Algorithm Hash digest
SHA256 fb1573d31f0955a19450c3e4152f7d0e5a83cdb0f50afd19f68ac9d1a34769bc
MD5 ed3715e870e29e0be5ffee95be61025e
BLAKE2b-256 f87e1d53f011d1526d2a2cb0c23e344139f0590fefa650f98acbb99dfd5bd2c1

See more details on using hashes here.

File details

Details for the file plotly_resampler-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: plotly_resampler-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.7.5 Linux/4.15.0-23-generic

File hashes

Hashes for plotly_resampler-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e99efe65d591778c778b1f2a816c9546e3b94bd83c72ed31dcc4f08ea2431723
MD5 de1af8b7a1030ce4711388677f1ba02f
BLAKE2b-256 dde2a48ea9c52f9818cf74936a750127ad632901adc68165ee7ee559e8c26913

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page