.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "_gallery/misc/scatter_sizes_animation.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download__gallery_misc_scatter_sizes_animation.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr__gallery_misc_scatter_sizes_animation.py:


Scatter sizes animation
=======================

Animate scatter sizes

.. GENERATED FROM PYTHON SOURCE LINES 7-47



.. image-sg:: /_gallery/misc/images/sphx_glr_scatter_sizes_animation_001.webp
   :alt: scatter sizes animation
   :srcset: /_gallery/misc/images/sphx_glr_scatter_sizes_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 numpy as np
    import fastplotlib as fpl

    xs = np.linspace(0, 10 * np.pi, 1_000)
    # sine wave
    ys = np.sin(xs)
    data = np.column_stack([xs, ys])

    sizes = np.abs(ys) * 5

    figure = fpl.Figure(size=(700, 560))

    figure[0, 0].add_scatter(data, sizes=sizes, name="sine")


    i = 0
    def update_sizes(subplot):
        global i

        xs = np.linspace(0.1 * i, (10 * np.pi) + (0.1 * i), 1_000)
        sizes = np.abs(np.sin(xs)) * 5

        subplot["sine"].sizes = sizes

        i += 1


    figure[0, 0].add_animations(update_sizes)

    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.loop.run()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 10.725 seconds)


.. _sphx_glr_download__gallery_misc_scatter_sizes_animation.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: scatter_sizes_animation.ipynb <scatter_sizes_animation.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: scatter_sizes_animation.py <scatter_sizes_animation.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: scatter_sizes_animation.zip <scatter_sizes_animation.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_