.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\Markers\ragged_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_auto_examples_Markers_ragged_points.py: Ragged Points ============= As for ragged signals, the number of markers at each position can vary and this is done by passing a ragged array to the constructor of the markers. .. GENERATED FROM PYTHON SOURCE LINES 10-11 Create a signal .. GENERATED FROM PYTHON SOURCE LINES 11-20 .. 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.arange(25*100*100).reshape((25, 100, 100)) s = hs.signals.Signal2D(data) .. GENERATED FROM PYTHON SOURCE LINES 21-23 Create the ragged array with varying number of markers for each navigation position .. GENERATED FROM PYTHON SOURCE LINES 23-37 .. code-block:: Python offsets = np.empty(s.axes_manager.navigation_shape, dtype=object) for ind in np.ndindex(offsets.shape): num = rng.integers(3, 10) offsets[ind] = rng.random((num, 2)) * 100 m = hs.plot.markers.Points( offsets=offsets, facecolor='orange', ) s.plot() s.add_marker(m) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/Markers/images/sphx_glr_ragged_points_001.png :alt: ragged points :srcset: /auto_examples/Markers/images/sphx_glr_ragged_points_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/Markers/images/sphx_glr_ragged_points_002.png :alt: Signal :srcset: /auto_examples/Markers/images/sphx_glr_ragged_points_002.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 38-39 sphinx_gallery_thumbnail_number = 2 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.321 seconds) .. _sphx_glr_download_auto_examples_Markers_ragged_points.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ragged_points.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ragged_points.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_