.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/Markers/circles_color_radius.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_circles_color_radius.py: Circle Markers with Radius Dependent Coloring ============================================= This example shows how to draw circle with the color of the circle scaling with the radius of the circle .. 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 matplotlib.pyplot as plt import numpy as np # Create a Signal2D rng = np.random.default_rng(0) s = hs.signals.Signal2D(np.ones((25, 100, 100))) .. GENERATED FROM PYTHON SOURCE LINES 21-22 This first example shows how to draw arrows .. GENERATED FROM PYTHON SOURCE LINES 22-38 .. code-block:: Python # Define the size of the circles sizes = rng.random((10, )) * 20 + 5 # Define the position of the circles offsets = rng.random((10, 2)) * 100 m = hs.plot.markers.Circles( sizes=sizes, offsets=offsets, linewidth=2, ) s.plot() s.add_marker(m) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/Markers/images/sphx_glr_circles_color_radius_001.png :alt: circles color radius :srcset: /auto_examples/Markers/images/sphx_glr_circles_color_radius_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/Markers/images/sphx_glr_circles_color_radius_002.png :alt: Signal :srcset: /auto_examples/Markers/images/sphx_glr_circles_color_radius_002.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 39-42 .. note:: Any changes to the marker made by setting :py:class:`matplotlib.collections.Collection` attributes will not be saved when saving as ``hspy``/``zspy`` file. .. GENERATED FROM PYTHON SOURCE LINES 42-55 .. code-block:: Python # Set the color of the circles m.set_ScalarMappable_array(sizes.ravel() / 2) # Add corresponding colorbar cbar = m.plot_colorbar() cbar.set_label('Circle radius') # Set animated state of colorbar to support blitting animated = plt.gcf().canvas.supports_blit cbar.ax.yaxis.set_animated(animated) cbar.solids.set_animated(animated) .. image-sg:: /auto_examples/Markers/images/sphx_glr_circles_color_radius_003.png :alt: circles color radius :srcset: /auto_examples/Markers/images/sphx_glr_circles_color_radius_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 56-57 sphinx_gallery_thumbnail_number = .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.805 seconds) .. _sphx_glr_download_auto_examples_Markers_circles_color_radius.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: circles_color_radius.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: circles_color_radius.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_