.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/ndwidget/timeseries2.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_timeseries2.py: NDWidget Timeseries cmaps ========================= NDWidget timeseries example with colormaps and transforms, can be useful for things like ethograms. .. GENERATED FROM PYTHON SOURCE LINES 7-88 .. image-sg:: /_gallery/ndwidget/images/sphx_glr_timeseries2_001.webp :alt: timeseries2 :srcset: /_gallery/ndwidget/images/sphx_glr_timeseries2_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_lines = 8 xs = np.linspace(0, 1000 * np.pi, n_datapoints) ys = np.random.rand(n_datapoints) data = np.column_stack([xs, ys]) n_data = np.stack([data] * n_lines) n_data2 = np.stack([data] * n_lines) n_data3 = np.stack([data] * n_lines) n_data2[..., 1] *= 2 n_data3[..., 1] *= 0.5 # 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), } ndw = fpl.NDWidget(ranges=ref, size=(700, 560), shape=(3, 1)) nd_lines = ndw[0, 0].add_nd_timeseries( n_data, ("n_lines", "angle", "d"), ("n_lines", "angle", "d"), slider_maps={ "angle": xs, }, x_range_mode="auto", display_window=np.pi * 10, ) nd_lines2 = ndw[1, 0].add_nd_timeseries( n_data2, ("n_lines", "angle", "d"), ("n_lines", "angle", "d"), slider_maps={ "angle": xs, }, x_range_mode="auto", display_window=np.pi * 10, ) nd_lines3 = ndw[2, 0].add_nd_timeseries( n_data3, ("n_lines", "angle", "d"), ("n_lines", "angle", "d"), slider_maps={ "angle": xs, }, x_range_mode="auto", display_window=np.pi * 10, ) ndw.show(maintain_aspect=False) figure = ndw.figure subplot = ndw.figure[0, 0] subplot2 = ndw.figure[1, 0] subplot3 = ndw.figure[2, 0] subplot.controller.add_camera(subplot2.camera, include_state={"x", "width"}) subplot.controller.add_camera(subplot3.camera, include_state={"x", "width"}) subplot2.controller.add_camera(subplot.camera, include_state={"x", "width"}) subplot2.controller.add_camera(subplot3.camera, include_state={"x", "width"}) subplot3.controller.add_camera(subplot2.camera, include_state={"x", "width"}) subplot3.controller.add_camera(subplot.camera, include_state={"x", "width"}) # 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 13.949 seconds) .. _sphx_glr_download__gallery_ndwidget_timeseries2.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: timeseries2.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: timeseries2.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_