|
| 1 | +.. role:: raw-html(raw) |
| 2 | + :format: html |
| 3 | + |
| 4 | +.. |br| raw:: html |
| 5 | + |
| 6 | + <br> |
| 7 | + |
| 8 | + |
| 9 | +FAQ ❓ |
| 10 | +====== |
| 11 | + |
| 12 | +.. raw:: html |
| 13 | + |
| 14 | + <details> |
| 15 | + <summary> |
| 16 | + <a><b>What does the orange <b style="color:orange">~ time|number </b> suffix in legend name indicate?</b></a> |
| 17 | + </summary> |
| 18 | + <div style="margin-left:1em"> |
| 19 | + |
| 20 | + |
| 21 | +This tilde suffix is only shown when the data is aggregated and represents the *mean aggregation bin size* which is the mean index-range difference between two consecutive aggregated samples. |
| 22 | + |
| 23 | + * for *time-indexed data*: the mean time-range between 2 consecutive (sampled) samples. |
| 24 | + * for *numeric-indexed data*: the mean numeric range between 2 consecutive (sampled) samples. |
| 25 | + |
| 26 | +When the index is a range-index; the *mean aggregation bin size* represents the *mean* downsample ratio; i.e., the mean number of samples that are aggregated into one sample. |
| 27 | + |
| 28 | +.. raw:: html |
| 29 | + |
| 30 | + </div> |
| 31 | + </details> |
| 32 | + <br> |
| 33 | + <details> |
| 34 | + <summary> |
| 35 | + <a><b>What is the difference between plotly-resampler figures and plain plotly figures?</b></a> |
| 36 | + </summary> |
| 37 | + <div style="margin-left:1em"> |
| 38 | + |
| 39 | +plotly-resampler can be thought of as wrapper around plain plotly figures which adds line-chart visualization scalability by dynamically aggregating the data of the figures w.r.t. the front-end view. plotly-resampler thus adds dynamic aggregation functionality to plain plotly figures. |
| 40 | + |
| 41 | +**important to know**: |
| 42 | + |
| 43 | +* ``show`` *always* returns a static html view of the figure, i.e., no dynamic aggregation can be performed on that view. |
| 44 | +* To have dynamic aggregation: |
| 45 | + |
| 46 | + * with ``FigureResampler``, you need to call ``show_dash`` (or output the object in a cell via ``IPython.display``) -> which spawns a dash-web app, and the dynamic aggregation is realized with dash callback |
| 47 | + * with ``FigureWidgetResampler``, you need to use ``IPython.display`` on the object, which uses widget-events to realize dynamic aggregation (via the running IPython kernel). |
| 48 | + |
| 49 | +.. raw:: html |
| 50 | + |
| 51 | + </div> |
| 52 | + </details> |
| 53 | + <br> |
| 54 | + <details> |
| 55 | + <summary> |
| 56 | + <a><b>What does <code><a href="https://github.com/predict-idlab/trace-updater" target="_blank">TraceUpdater</a></code> do?</b></a> |
| 57 | + </summary> |
| 58 | + <div style="margin-left:1em"> |
| 59 | + |
| 60 | +The ``TraceUpdater`` class is a custom dash component that aids ``dcc.Graph`` components to efficiently send and update (in our case aggregated) data to the front-end. |
| 61 | + |
| 62 | +For more information on how to use the trace-updater component together with the ``FigureResampler``, see our dash app `examples <https://github.com/predict-idlab/plotly-resampler/tree/main/examples>`_` and look at the `trace-updater <https://github.com/predict-idlab/trace-updater/blob/master/trace_updater/TraceUpdater.py>`_ its documentation. |
| 63 | + |
| 64 | +.. raw:: html |
| 65 | + |
| 66 | + </div> |
| 67 | + </details> |
| 68 | + <br> |
| 69 | + <details> |
| 70 | + <summary> |
| 71 | + <a><b>What is the difference in approach between plotly-resampler and datashader?</b></a> |
| 72 | + </summary> |
| 73 | + <div style="margin-left:1em"> |
| 74 | + |
| 75 | + |
| 76 | +`Datashader <https://datashader.org/getting_started/Introduction.html>`_ is a highly scalable `open-source <https://github.com/holoviz/datashader>`_ library for analyzing and visualizing large datasets. More specifically, datashader *“rasterizes”* or *“aggregates”* datasets into regular grids that can be analyzed further or viewed as **images**. |
| 77 | + |
| 78 | + |
| 79 | +**The main differences are**: |
| 80 | + |
| 81 | +Datashader can deal with various kinds of data (e.g., location related data, point clouds), whereas plotly-resampler is more tailored towards time-series data visualizations. |
| 82 | +Furthermore, datashader outputs a **rasterized image/array** encompassing all traces their data, whereas plotly-resampler outputs an **aggregated series** per trace. Thus, datashader is more suited for analyzing data where you do not want to pin-out a certain series/trace. |
| 83 | + |
| 84 | +In our opinion, datashader truly shines (for the time series use case) when: |
| 85 | + |
| 86 | +* you want a global, overlaying view of all your traces |
| 87 | +* you want to visualize a large number of time series in a single plot (many traces) |
| 88 | +* there is a lot of noise on your high-frequency data and you want to uncover the underlying pattern |
| 89 | +* you want to render all data points in your visualization |
| 90 | + |
| 91 | +In our opinion, plotly-resampler shines when: |
| 92 | + |
| 93 | +* you need the capabilities to interact with the traces (e.g., hovering, toggling traces, hovertext per trace) |
| 94 | +* you want to use a less complex (but more restricted) visualization interface (as opposed to holoviews), i.e., plotly |
| 95 | +* you want to make existing plotly time-series figures more scalable and efficient |
| 96 | +* to build scalable Dash apps for time-series data visualization |
| 97 | + |
| 98 | +Furthermore combined with holoviews, datashader can also be employed in an interactive manner, see the example below. |
| 99 | + |
| 100 | +.. code:: python |
| 101 | +
|
| 102 | + from holoviews.operation.datashader import datashade |
| 103 | + import datashader as ds |
| 104 | + import holoviews as hv |
| 105 | + import numpy as np |
| 106 | + import pandas as pd |
| 107 | + import panel as pn |
| 108 | +
|
| 109 | + hv.extension("bokeh") |
| 110 | + pn.extension(comms='ipywidgets') |
| 111 | +
|
| 112 | + # Create the dummy dataframe |
| 113 | + n = 1_000_000 |
| 114 | + x = np.arange(n) |
| 115 | + noisy_sine = (np.sin(x / 3_000) + (np.random.randn(n) / 10)) * x / 5_000 |
| 116 | + df = pd.DataFrame( |
| 117 | + {"ns": noisy_sine, "ns_abs": np.abs(noisy_sine),} |
| 118 | + ) |
| 119 | +
|
| 120 | + # Visualize interactively with datashader |
| 121 | + opts = hv.opts.RGB(width=800, height=400) |
| 122 | + ndoverlay = hv.NdOverlay({c:hv.Curve((df.index, df[c])) for c in df.columns}) |
| 123 | + datashade(ndoverlay, cnorm='linear', aggregator=ds.count(), line_width=3).opts(opts) |
| 124 | +
|
| 125 | +.. image:: _static/datashader.png |
| 126 | + |
| 127 | + |
| 128 | +.. raw:: html |
| 129 | + |
| 130 | + </div> |
| 131 | + </details> |
| 132 | + <br> |
| 133 | + <details> |
| 134 | + <summary> |
| 135 | + <a><b>I get errors such as:</b><br><ul><li> |
| 136 | + <code>RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xe</code></li> |
| 137 | + <li><code>ImportError: numpy.core.multiarray failed to import</code></li> |
| 138 | + </ul> |
| 139 | + </a> |
| 140 | + </summary> |
| 141 | + <div style="margin-left:1em"> |
| 142 | + |
| 143 | + Plotly-resampler uses compiled C code (which uses the NumPy C API) to speed up the LTTB data-aggregation algorithm. This C code gets compiled during the building stage of the package (which might be before you install the package).<br><br> |
| 144 | + If this C extension was build against a more recent NumPy version than your local version, you obtain a |
| 145 | + <a href="https://numpy.org/devdocs/user/troubleshooting-importerror.html#c-api-incompatibility"><i>NumPy C-API incompatibility</i></a> |
| 146 | + and the above error will be raised.<br><br> |
| 147 | + |
| 148 | + These above mentioned errors can thus be resolved by running<br> |
| 149 | + <code>pip install --upgrade numpy</code><br> |
| 150 | + and reinstalling plotly-resampler afterwards.<br><br> |
| 151 | + |
| 152 | + For more information about compatibility and building upon NumPy, you can consult |
| 153 | + <a href="https://numpy.org/doc/stable/user/depending_on_numpy.html?highlight=compiled#for-downstream-package-authors">NumPy's docs for downstream package authors</a>. |
| 154 | + |
| 155 | + We aim to limit this issue as much as possible (by for example using <a href="https://github.com/scipy/oldest-supported-numpy">oldest-supported-numpy</a> in our build.py), |
| 156 | + but if you still experience issues, please open an issue on <a href="https://github.com/predict-idlab/plotly-resampler/issues">GitHub</a>. |
| 157 | + |
| 158 | +.. raw:: html |
| 159 | + |
| 160 | + </div> |
| 161 | + </details> |
| 162 | + <br> |
0 commit comments