.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/Markers/ellipses.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_ellipses.py: Ellipse markers =============== .. GENERATED FROM PYTHON SOURCE LINES 7-8 Create a signal .. GENERATED FROM PYTHON SOURCE LINES 8-17 .. 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((25, 25, 100, 100)) s = hs.signals.Signal2D(data) .. GENERATED FROM PYTHON SOURCE LINES 18-19 This first example shows how to draw static ellipses .. GENERATED FROM PYTHON SOURCE LINES 19-34 .. code-block:: Python # Define the position of the ellipses offsets = rng.random((10, 2)) * 100 m = hs.plot.markers.Ellipses( widths=(8,), heights=(10,), angles=(45,), offsets=offsets, facecolor="red", ) s.plot() s.add_marker(m) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/Markers/images/sphx_glr_ellipses_001.png :alt: ellipses :srcset: /auto_examples/Markers/images/sphx_glr_ellipses_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/Markers/images/sphx_glr_ellipses_002.png :alt: Signal :srcset: /auto_examples/Markers/images/sphx_glr_ellipses_002.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 35-40 Dynamic Ellipse Markers ####################### This first example shows how to draw dynamic ellipses, whose position, widths heights and angles depends on the navigation coordinates .. GENERATED FROM PYTHON SOURCE LINES 41-67 .. code-block:: Python s2 = hs.signals.Signal2D(data) widths = np.empty(s.axes_manager.navigation_shape, dtype=object) heights = np.empty(s.axes_manager.navigation_shape, dtype=object) angles = np.empty(s.axes_manager.navigation_shape, dtype=object) offsets = np.empty(s.axes_manager.navigation_shape, dtype=object) for index in np.ndindex(offsets.shape): widths[index] = rng.random((10, )) * 10 heights[index] = rng.random((10, )) * 7 angles[index] = rng.random((10, )) * 180 offsets[index] = rng.random((10, 2)) * 100 m = hs.plot.markers.Ellipses( widths=widths, heights=heights, angles=angles, offsets=offsets, facecolor="red", ) s2.plot() s2.add_marker(m) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/Markers/images/sphx_glr_ellipses_003.png :alt: ellipses :srcset: /auto_examples/Markers/images/sphx_glr_ellipses_003.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/Markers/images/sphx_glr_ellipses_004.png :alt: Signal :srcset: /auto_examples/Markers/images/sphx_glr_ellipses_004.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 68-69 sphinx_gallery_thumbnail_number = 2 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.969 seconds) .. _sphx_glr_download_auto_examples_Markers_ellipses.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ellipses.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ellipses.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_