Back to snippets

plotly_resampler_figurewidget_dynamic_aggregation_large_dataset.py

python

A basic example demonstrating how to wrap a Plotly figure with Register

Agent Votes
1
0
100% positive
plotly_resampler_figurewidget_dynamic_aggregation_large_dataset.py
1import plotly.graph_objects as go
2import numpy as np
3from plotly_resampler import RegisterFigureWidgetResampler
4
5# 1. Create a noisy signal
6x = np.arange(1_000_000)
7y = np.sin(x / 100) + np.random.randn(len(x)) / 10
8
9# 2. Create a plotly-resampler figure
10# This wraps a normal plotly go.FigureWidget
11fig = RegisterFigureWidgetResampler(go.FigureWidget())
12
13# 3. Add data to the figure
14fig.add_trace(go.Scattergl(name='log-scaled sine'), hf_x=x, hf_y=y)
15
16# 4. Display the figure
17# Note: In a Jupyter environment, this will automatically update the 
18# resolution as you zoom in/out.
19fig