.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/misc/line_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_line_animation.py: Simple Line Animation ===================== Example showing animation with lines. .. GENERATED FROM PYTHON SOURCE LINES 7-50 .. image-sg:: /_gallery/misc/images/sphx_glr_line_animation_001.webp :alt: line animation :srcset: /_gallery/misc/images/sphx_glr_line_animation_001.webp :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /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 fastplotlib as fpl import numpy as np # generate some data start, stop = 0, 2 * np.pi increment = (2 * np.pi) / 50 # make a simple sine wave xs = np.linspace(start, stop, 100) ys = np.sin(xs) figure = fpl.Figure(size=(700, 560)) # plot the image data sine = figure[0, 0].add_line(ys, name="sine", colors="r") # increment along the x-axis on each render loop :D def update_line(subplot): global increment, start, stop xs = np.linspace(start + increment, stop + increment, 100) ys = np.sin(xs) start += increment stop += increment # change only the y-axis values of the line subplot["sine"].data[:, 1] = ys figure[0, 0].add_animations(update_line) figure.show(maintain_aspect=False) # 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 5.561 seconds) .. _sphx_glr_download__gallery_misc_line_animation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: line_animation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: line_animation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: line_animation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_