Skip to content

Commit 126f84a

Browse files
committed
🍍 improving docs + 🔍
1 parent 74f1d41 commit 126f84a

File tree

3 files changed

+54
-10
lines changed

3 files changed

+54
-10
lines changed

plotly_resampler/figure_resampler/figure_resampler.py

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,53 @@ def __init__(
4343
verbose: bool = False,
4444
show_dash_kwargs: dict | None = None,
4545
):
46+
"""Initialize a dynamic aggregation data mirror using a dash web app.
47+
48+
Parameters
49+
----------
50+
figure: BaseFigure
51+
The figure that will be decorated. Can be either an empty figure
52+
(e.g., ``go.Figure()``, ``make_subplots()``, ``go.FigureWidget``) or an
53+
existing figure.
54+
convert_existing_traces: bool
55+
A bool indicating whether the high-frequency traces of the passed ``figure``
56+
should be resampled, by default True. Hence, when set to False, the
57+
high-frequency traces of the passed ``figure`` will not be resampled.
58+
default_n_shown_samples: int, optional
59+
The default number of samples that will be shown for each trace,
60+
by default 1000.\n
61+
.. note::
62+
* This can be overridden within the :func:`add_trace` method.
63+
* If a trace withholds fewer datapoints than this parameter,
64+
the data will *not* be aggregated.
65+
default_downsampler: AbstractSeriesDownsampler
66+
An instance which implements the AbstractSeriesDownsampler interface and
67+
will be used as default downsampler, by default ``EfficientLTTB`` with
68+
_interleave_gaps_ set to True. \n
69+
.. note:: This can be overridden within the :func:`add_trace` method.
70+
resampled_trace_prefix_suffix: str, optional
71+
A tuple which contains the ``prefix`` and ``suffix``, respectively, which
72+
will be added to the trace its legend-name when a resampled version of the
73+
trace is shown. By default a bold, orange ``[R]`` is shown as prefix
74+
(no suffix is shown).
75+
show_mean_aggregation_size: bool, optional
76+
Whether the mean aggregation bin size will be added as a suffix to the trace
77+
its legend-name, by default True.
78+
convert_traces_kwargs: dict, optional
79+
A dict of kwargs that will be passed to the :func:`add_traces` method and
80+
will be used to convert the existing traces. \n
81+
.. note::
82+
This argument is only used when the passed ``figure`` contains data and
83+
``convert_existing_traces`` is set to True.
84+
verbose: bool, optional
85+
Whether some verbose messages will be printed or not, by default False.
86+
show_dash_kwargs: dict, optional
87+
A dict that will be used as default kwargs for the :func:`show_dash` method.
88+
Note that the passed kwargs will be take precedence over these defaults.
89+
90+
"""
4691
# Parse the figure input before calling `super`
47-
if is_figure(figure) and not is_fr(figure):
92+
if is_figure(figure) and not is_fr(figure):
4893
# A go.Figure
4994
# => base case: the figure does not need to be adjusted
5095
f = figure
@@ -55,7 +100,7 @@ def __init__(
55100
f._data_validator.set_uid = False
56101

57102
if isinstance(figure, BaseFigure):
58-
# A base figure object, can be;
103+
# A base figure object, can be;
59104
# - a go.FigureWidget
60105
# - a plotly-resampler figure: subclass of AbstractFigureAggregator
61106
# => we first copy the layout, grid_str and grid ref
@@ -75,7 +120,7 @@ def __init__(
75120
f._grid_ref = figure.get("_grid_ref")
76121
f.add_traces(figure.get("data"))
77122
# `pr_props` is not None when loading a pickled plotly-resampler figure
78-
f._pr_props = figure.get("pr_props")
123+
f._pr_props = figure.get("pr_props")
79124
# `f._pr_props`` is an attribute to store properties of a
80125
# plotly-resampler figure. This attribute is only used to pass
81126
# information to the super() constructor. Once the super constructor is
@@ -156,8 +201,8 @@ def show_dash(
156201
``config`` parameter for this property in this method.
157202
See more https://dash.plotly.com/dash-core-components/graph
158203
**kwargs: dict
159-
Additional app.run_server() kwargs. e.g.: port
160-
Note that these kwargs take precedence over the ones passed to the
204+
Additional app.run_server() kwargs. e.g.: port, ...
205+
Also note that these kwargs take precedence over the ones passed to the
161206
constructor via the ``show_dash_kwargs`` argument.
162207
163208
"""
@@ -183,7 +228,7 @@ def show_dash(
183228
and "height" not in kwargs
184229
):
185230
# If app height is not specified -> re-use figure height for inline dash app
186-
# Note: default layout height is 450 (whereas default app height is 650)
231+
# Note: default layout height is 450 (whereas default app height is 650)
187232
# See: https://plotly.com/python/reference/layout/#layout-height
188233
fig_height = self.layout.height if self.layout.height is not None else 450
189234
kwargs["height"] = fig_height + 18

plotly_resampler/figure_resampler/figure_resampler_interface.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def __init__(
5050
show_mean_aggregation_size: bool = True,
5151
convert_traces_kwargs: dict | None = None,
5252
verbose: bool = False,
53-
pr_props: dict | None = None,
5453
):
5554
"""Instantiate a resampling data mirror.
5655

plotly_resampler/figure_resampler/figurewidget_resampler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def __init__(
5656
f = self._get_figure_class(go.FigureWidget)()
5757
f._data_validator.set_uid = False
5858

59-
if isinstance(figure, BaseFigure):
60-
# A base figure object, can be;
59+
if isinstance(figure, BaseFigure):
60+
# A base figure object, can be;
6161
# - a base plotly figure: go.Figure or go.FigureWidget
6262
# - a plotly-resampler figure: subclass of AbstractFigureAggregator
6363
# => we first copy the layout, grid_str and grid ref
@@ -76,7 +76,7 @@ def __init__(
7676
f._grid_ref = figure.get("_grid_ref")
7777
f.add_traces(figure.get("data"))
7878
# `pr_props` is not None when loading a pickled plotly-resampler figure
79-
f._pr_props = figure.get("pr_props")
79+
f._pr_props = figure.get("pr_props")
8080
# `f._pr_props`` is an attribute to store properties of a plotly-resampler
8181
# figure. This attribute is only used to pass information to the super()
8282
# constructor. Once the super constructor is called, the attribute is

0 commit comments

Comments
 (0)