.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\Markers\filled_circles.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_filled_circles.py: Filled Circle Markers ===================== .. GENERATED FROM PYTHON SOURCE LINES 7-8 Create a signal .. GENERATED FROM PYTHON SOURCE LINES 8-18 .. code-block:: Python import hyperspy.api as hs import matplotlib as mpl 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 19-20 This first example shows how to draw static filled circles .. GENERATED FROM PYTHON SOURCE LINES 20-33 .. code-block:: Python # Define the position of the circles offsets = rng.random((10, 2)) * 100 m = hs.plot.markers.Points( sizes=20, offsets=offsets, facecolors="red", ) s.plot() s.add_marker(m) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/Markers/images/sphx_glr_filled_circles_001.png :alt: filled circles :srcset: /auto_examples/Markers/images/sphx_glr_filled_circles_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/Markers/images/sphx_glr_filled_circles_002.png :alt: Signal :srcset: /auto_examples/Markers/images/sphx_glr_filled_circles_002.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 34-39 Dynamic Filled Circle Markers ############################# This second example shows how to draw dynamic filled circles, whose size, color and position change depending on the navigation position .. GENERATED FROM PYTHON SOURCE LINES 40-60 .. code-block:: Python s2 = hs.signals.Signal2D(data) offsets = np.empty(s.axes_manager.navigation_shape, dtype=object) sizes = np.empty(s.axes_manager.navigation_shape, dtype=object) colors = list(mpl.colors.TABLEAU_COLORS.values())[:10] for ind in np.ndindex(offsets.shape): offsets[ind] = rng.random((10, 2)) * 100 sizes[ind] = rng.random((10, )) * 50 m = hs.plot.markers.Points( sizes=sizes, offsets=offsets, facecolors=colors, ) s2.plot() s2.add_marker(m) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/Markers/images/sphx_glr_filled_circles_003.png :alt: filled circles :srcset: /auto_examples/Markers/images/sphx_glr_filled_circles_003.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/Markers/images/sphx_glr_filled_circles_004.png :alt: Signal :srcset: /auto_examples/Markers/images/sphx_glr_filled_circles_004.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 61-62 sphinx_gallery_thumbnail_number = 2 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.205 seconds) .. _sphx_glr_download_auto_examples_Markers_filled_circles.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: filled_circles.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: filled_circles.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_