.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/ndwidget/timeseries.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__gallery_ndwidget_timeseries.py: NDWidget Timeseries =================== NDWidget timeseries example .. GENERATED FROM PYTHON SOURCE LINES 7-69 .. image-sg:: /_gallery/ndwidget/images/sphx_glr_timeseries_001.webp :alt: timeseries :srcset: /_gallery/ndwidget/images/sphx_glr_timeseries_001.webp :class: sphx-glr-single-img .. code-block:: Python # test_example = true import numpy as np import fastplotlib as fpl # generate some toy timeseries data n_datapoints = 100_000 # number of datapoints per line n_freqs = 20 # number of frequencies n_ampls = 15 # number of amplitudes n_lines = 8 xs = np.linspace(0, 1000 * np.pi, n_datapoints) data = np.zeros(shape=(n_freqs, n_ampls, n_lines, n_datapoints, 2), dtype=np.float32) for freq in range(data.shape[0]): for ampl in range(data.shape[1]): ys = np.sin(xs * (freq + 1)) * (ampl + 1) + np.random.normal( 0, 0.1, size=n_datapoints ) line = np.column_stack([xs, ys]) data[freq, ampl] = np.stack([line] * n_lines) # must define a reference range, this would often be your time dimension and corresponds to your x-dimension ref = { "angle": (0, xs[-1], 0.1), "freq": (1, n_freqs + 1, 1), "ampl": (1, n_ampls + 1, 1), } ndw = fpl.NDWidget(ranges=ref, size=(700, 560)) nd_lines = ndw[0, 0].add_nd_timeseries( data, ("freq", "ampl", "n_lines", "angle", "d"), ("n_lines", "angle", "d"), slider_maps={ "angle": xs, "ampl": lambda x: int(x + 1), "freq": lambda x: int(x + 1), }, cmap="jet", x_range_mode="auto", display_window=np.pi * 10, name="nd-sine" ) nd_lines.cmap = "tab10" subplot = ndw.figure[0, 0] subplot.controller.add_camera(subplot.camera, include_state={"x", "width"}) ndw.show(maintain_aspect=False) figure = ndw.figure # NOTE: fpl.loop.run() should not be used for interactive sessions # See the "JupyterLab and IPython" section in the user guide if __name__ == "__main__": print(__doc__) fpl.loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 8.243 seconds) .. _sphx_glr_download__gallery_ndwidget_timeseries.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: timeseries.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: timeseries.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_