.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/vectors/vectors_simple.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_vectors_vectors_simple.py: Simple Vectors ============== Simple example with vectors. Similar to matplotlib quiver. .. GENERATED FROM PYTHON SOURCE LINES 8-43 .. image-sg:: /_gallery/vectors/images/sphx_glr_vectors_simple_001.webp :alt: vectors simple :srcset: /_gallery/vectors/images/sphx_glr_vectors_simple_001.webp :class: sphx-glr-single-img .. code-block:: Python # test_example = true import numpy as np import fastplotlib as fpl figure = fpl.Figure(size=(700, 700)) start, stop, step = 0, 2 * np.pi, 0.2 # get uniform x, y positions x, y = np.meshgrid(np.arange(start, stop, step), np.arange(start, stop, step)) # vectors, u and v are x and y components indicating directions u = np.cos(x) v = np.sin(y) # positions of each vector as [n_points, 2] array positions = np.column_stack([x.ravel(), y.ravel()]) # directions of each vector as a [n_points, 2] array directions = np.column_stack([u.ravel(), v.ravel()]) vectors = figure[0, 0].add_vectors( positions=positions, directions=directions, ) 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.753 seconds) .. _sphx_glr_download__gallery_vectors_vectors_simple.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: vectors_simple.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: vectors_simple.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_