.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/misc/line3d_animation.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_misc_line3d_animation.py: Simple 3D Line Animation ======================== Example showing animation with 3D lines. .. GENERATED FROM PYTHON SOURCE LINES 7-61 .. image-sg:: /_gallery/misc/images/sphx_glr_line3d_animation_001.webp :alt: line3d animation :srcset: /_gallery/misc/images/sphx_glr_line3d_animation_001.webp :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:266: RuntimeWarning: divide by zero encountered in divide screen_full = (ndc_full[:, :2] / ndc_full[:, 3:4]) * half_canvas_size /opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:266: RuntimeWarning: invalid value encountered in divide screen_full = (ndc_full[:, :2] / ndc_full[:, 3:4]) * half_canvas_size /opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:278: RuntimeWarning: invalid value encountered in divide screen_sel = (ndc_sel[:, :2] / ndc_sel[:, 3:4]) * half_canvas_size /home/runner/work/fastplotlib/fastplotlib/fastplotlib/graphics/_features/_base.py:18: UserWarning: casting float64 array to float32 warn(f"casting {array.dtype} array to float32") | .. code-block:: Python # test_example = false import numpy as np import fastplotlib as fpl # create data in the shape of a spiral phi = np.linspace(0, 30, 200) xs = phi * np.cos(phi) ys = phi * np.sin(phi) zs = phi # make data 3d, with shape [, 3] spiral = np.dstack([xs, ys, zs])[0] figure = fpl.Figure(cameras="3d", size=(700, 560)) line_graphic = figure[0,0].add_line(data=spiral, thickness=3, cmap='jet') marker = figure[0,0].add_scatter(data=spiral[0], sizes=10, name="marker") marker_index = 0 # a function to move the ball along the spiral def move_marker(): global marker_index marker_index += 1 if marker_index == spiral.shape[0]: marker_index = 0 for subplot in figure: subplot["marker"].data = spiral[marker_index] # add `move_marker` to the animations figure.add_animations(move_marker) # remove clutter figure[0, 0].axes.grids.xy.visible = True figure[0, 0].axes.grids.xz.visible = True figure.show() # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter if __name__ == "__main__": print(__doc__) fpl.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 18.033 seconds) .. _sphx_glr_download__gallery_misc_line3d_animation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: line3d_animation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: line3d_animation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: line3d_animation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_