.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/scatter/scatter_image_as_points.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_scatter_scatter_image_as_points.py: Scatter image as points ======================= Display a scatter using an image as the points. These are also called sprites. .. GENERATED FROM PYTHON SOURCE LINES 7-55 .. image-sg:: /_gallery/scatter/images/sphx_glr_scatter_image_as_points_001.webp :alt: scatter image as points :srcset: /_gallery/scatter/images/sphx_glr_scatter_image_as_points_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 = true import numpy as np import fastplotlib as fpl import imageio.v3 as iio xs = np.linspace(0, 2 * np.pi, 10) # make sine and cosine data sine = np.column_stack([xs, np.sin(xs)]) cosine = np.column_stack([xs, np.cos(xs)]) # a simple image to display as the points array = np.array([ [1, 0, 1], [0, 1, 0], [1, 1, 1], ]) # load an image of Almar's cat wikkie = np.flipud(iio.imread("imageio:wikkie.png")) figure = fpl.Figure(size=(700, 350)) scatter = figure[0, 0].add_scatter( data=sine, mode="image", # mode must be "image", otherwise the `image` arg is ignored and markers are used image=array, cmap="jet", # the image is multiplied by the scatter point colors if provided sizes=25, ) scatter2 = figure[0, 0].add_scatter( data=cosine, mode="image", image=wikkie, # if an RGB(A) image is provided and no colors are provided, then the image is shown as-is sizes=40, ) figure.show() # 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 0.537 seconds) .. _sphx_glr_download__gallery_scatter_scatter_image_as_points.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: scatter_image_as_points.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: scatter_image_as_points.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_