@@ -47,12 +47,54 @@ In [this Plotly-Resampler demo](https://github.com/predict-idlab/plotly-resample
47
47
## Usage
48
48
49
49
To ** add dynamic resampling** to your plotly Figure
50
- * using a web application with * Dash * callbacks, you should;
51
- 1 . wrap the plotly Figure with ` FigureResampler `
52
- 2 . call ` .show_dash() ` on the Figure
53
- * within a * jupyter * environment and * without creating a web application * , you should:
50
+ < details >
51
+ < summary >within a < b >< i >jupyter</ i > environment without creating a < i >web application</ i ></ b ></ summary >
52
+ < br >
53
+
54
54
1 . wrap the plotly Figure with ` FigureWidgetResampler `
55
55
2 . output the ` FigureWidgetResampler ` instance in a cell
56
+
57
+ ** example code** :
58
+ ``` python
59
+ import plotly.graph_objects as go; import numpy as np
60
+ from plotly_resampler import FigureResampler, FigureWidgetResampler
61
+
62
+ x = np.arange(1_000_000 )
63
+ noisy_sin = (3 + np.sin(x / 200 ) + np.random.randn(len (x)) / 10 ) * x / 1_000
64
+
65
+ # OPTION 1 - FigureWidgetResampler: dynamic aggregation via `FigureWidget.layout.on_change`
66
+ fig = FigureWidgetResampler(go.Figure())
67
+ fig.add_trace(go.Scattergl(name = ' noisy sine' , showlegend = True ), hf_x = x, hf_y = noisy_sin)
68
+
69
+ fig
70
+ ```
71
+
72
+ </details >
73
+ <details >
74
+ <summary>using a <b><i>web-application</i> with <a href="https://github.com/plotly/dash">dash</a></b> callbacks</summary>
75
+ <br >
76
+
77
+ 1 . wrap the plotly Figure with ` FigureResampler `
78
+ 2 . call ` .show_dash() ` on the ` Figure `
79
+
80
+ ** example code** :
81
+ ``` python
82
+ import plotly.graph_objects as go; import numpy as np
83
+ from plotly_resampler import FigureResampler, FigureWidgetResampler
84
+
85
+ x = np.arange(1_000_000 )
86
+ noisy_sin = (3 + np.sin(x / 200 ) + np.random.randn(len (x)) / 10 ) * x / 1_000
87
+
88
+ # OPTION 2 - FigureResampler: dynamic aggregation via a Dash web-app
89
+ fig = FigureResampler(go.Figure())
90
+ fig.add_trace(go.Scattergl(name = ' noisy sine' , showlegend = True ), hf_x = x, hf_y = noisy_sin)
91
+
92
+ fig.show_dash(mode = ' inline' )
93
+ ```
94
+
95
+ </details >
96
+
97
+ ---
56
98
57
99
> ** Note** :
58
100
> Any plotly Figure can be wrapped with ` FigureResampler ` and ` FigureWidgetResampler ` ! 🎉
@@ -61,31 +103,6 @@ To **add dynamic resampling** to your plotly Figure
61
103
> ** Tip** 💡:
62
104
> For significant faster initial loading of the Figure, we advise to wrap the constructor of the plotly Figure and add the trace data as ` hf_x ` and ` hf_y `
63
105
64
- ### Minimal example
65
-
66
- ``` python
67
- import plotly.graph_objects as go; import numpy as np
68
- from plotly_resampler import FigureResampler, FigureWidgetResampler
69
-
70
- x = np.arange(1_000_000 )
71
- noisy_sin = (3 + np.sin(x / 200 ) + np.random.randn(len (x)) / 10 ) * x / 1_000
72
-
73
- # OPTION 1 - FigureResampler: dynamic aggregation via a Dash web-app
74
- fig = FigureResampler(go.Figure())
75
- fig.add_trace(go.Scattergl(name = ' noisy sine' , showlegend = True ), hf_x = x, hf_y = noisy_sin)
76
-
77
- fig.show_dash(mode = ' inline' )
78
- ```
79
-
80
- #### FigureWidgetResampler: dynamic aggregation via ` FigureWidget.layout.on_change `
81
- ``` python
82
- ...
83
- # OPTION 2 - FigureWidgetResampler: dynamic aggregation via `FigureWidget.layout.on_change`
84
- fig = FigureWidgetResampler(go.Figure())
85
- fig.add_trace(go.Scattergl(name = ' noisy sine' , showlegend = True ), hf_x = x, hf_y = noisy_sin)
86
-
87
- fig
88
- ```
89
106
90
107
### Features
91
108
111
128
112
129
## Future work 🔨
113
130
114
- * Support ` .add_traces() ` (currently only ` .add_trace ` is supported)
131
+ - [x] Support ` .add_traces() ` (currently only ` .add_trace ` is supported)
115
132
116
133
<br >
117
134
0 commit comments