.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/Markers/rotation_makers.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_rotation_makers.py: Rotation of markers =================== This example shows how markers are rotated. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Create a signal .. GENERATED FROM PYTHON SOURCE LINES 10-22 .. code-block:: Python import hyperspy.api as hs import numpy as np # Create a Signal2D data = np.ones([100, 100]) s = hs.signals.Signal2D(data) num = 2 angle = 25 color = ["tab:orange", "tab:blue"] .. GENERATED FROM PYTHON SOURCE LINES 23-24 Create the markers, the first and second elements are at 0 and 20 degrees .. GENERATED FROM PYTHON SOURCE LINES 24-55 .. code-block:: Python # Define the position of the markers offsets = np.array([20*np.ones(num)]*2).T angles = np.arange(0, angle*num, angle) m1 = hs.plot.markers.Rectangles( offsets=offsets, widths=np.ones(num)*20, heights=np.ones(num)*10, angles=angles, facecolor='none', edgecolor=color, ) m2 = hs.plot.markers.Ellipses( offsets=offsets + np.array([0, 20]), widths=np.ones(num)*20, heights=np.ones(num)*10, angles=angles, facecolor='none', edgecolor=color, ) m3 = hs.plot.markers.Squares( offsets=offsets + np.array([0, 50]), widths=np.ones(num)*20, angles=angles, facecolor='none', edgecolor=color, ) .. GENERATED FROM PYTHON SOURCE LINES 56-57 Plot the signals and add all the markers .. GENERATED FROM PYTHON SOURCE LINES 57-61 .. code-block:: Python s.plot() s.add_marker([m1, m2, m3]) .. image-sg:: /auto_examples/Markers/images/sphx_glr_rotation_makers_001.png :alt: Signal :srcset: /auto_examples/Markers/images/sphx_glr_rotation_makers_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 62-63 sphinx_gallery_thumbnail_number = 1 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.499 seconds) .. _sphx_glr_download_auto_examples_Markers_rotation_makers.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: rotation_makers.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: rotation_makers.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: rotation_makers.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_