.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/Markers/arrows_ragged.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_auto_examples_Markers_arrows_ragged.py: Varying number of arrows per navigation position ================================================ .. GENERATED FROM PYTHON SOURCE LINES 7-8 Create a signal .. GENERATED FROM PYTHON SOURCE LINES 8-23 .. code-block:: Python import hyperspy.api as hs import numpy as np # Create a Signal2D with 2 navigation dimensions rng = np.random.default_rng(0) data = np.ones((10, 100, 100)) s = hs.signals.Signal2D(data) for axis in s.axes_manager.signal_axes: axis.scale = 2*np.pi / 100 # Select navigation position 5 s.axes_manager.indices = (5, ) .. GENERATED FROM PYTHON SOURCE LINES 24-29 Dynamic Arrow Markers: Changing Length ###################################### This example shows how to use the Arrows marker with a varying number of arrows per navigation position .. GENERATED FROM PYTHON SOURCE LINES 30-50 .. code-block:: Python # Define the position of the arrows, use ragged array to enable the navigation # position dependence offsets= np.empty(s.axes_manager.navigation_shape, dtype=object) U = np.empty(s.axes_manager.navigation_shape, dtype=object) V = np.empty(s.axes_manager.navigation_shape, dtype=object) for ind in np.ndindex(U.shape): offsets[ind] = rng.random((ind[0]+1, 2)) * 6 U[ind] = rng.random(ind[0]+1) * 2 V[ind] = rng.random(ind[0]+1) * 2 m = hs.plot.markers.Arrows( offsets, U, V, ) s.plot() s.add_marker(m) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/Markers/images/sphx_glr_arrows_ragged_001.png :alt: arrows ragged :srcset: /auto_examples/Markers/images/sphx_glr_arrows_ragged_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/Markers/images/sphx_glr_arrows_ragged_002.png :alt: Signal :srcset: /auto_examples/Markers/images/sphx_glr_arrows_ragged_002.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 51-52 sphinx_gallery_thumbnail_number = 2 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.733 seconds) .. _sphx_glr_download_auto_examples_Markers_arrows_ragged.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: arrows_ragged.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: arrows_ragged.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_