.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plotting/extraction_of_linescan.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_plotting_extraction_of_linescan.py: Extraction of linescan ====================== This example shows how to extract a linescan from a map using a region of interest (ROI). .. GENERATED FROM PYTHON SOURCE LINES 9-10 Load the data .. GENERATED FROM PYTHON SOURCE LINES 10-18 .. code-block:: Python import lumispy as lum import hyperspy.api as hs import numpy as np cl1 = lum.data.nanoparticles() cl2 = cl1.T.mean() cl2.data = cl2.data.astype(np.float32) .. GENERATED FROM PYTHON SOURCE LINES 19-20 First Intialize Line-ROI (:py:class:`hyperspy.api.roi.Line2DROI`) from position (100, 700) to position (900, 100) of width 20 in calibrated axes units .. GENERATED FROM PYTHON SOURCE LINES 20-25 .. code-block:: Python line_roi = hs.roi.Line2DROI(100, 700, 900, 100, 20) cl2.plot() line_roi2 = line_roi.interactive(cl2, color="red") # to show the ROI on the plot .. image-sg:: /auto_examples/plotting/images/sphx_glr_extraction_of_linescan_001.png :alt: cathodoluminescence_example Signal :srcset: /auto_examples/plotting/images/sphx_glr_extraction_of_linescan_001.png, /auto_examples/plotting/images/sphx_glr_extraction_of_linescan_001_5_00x.png 5.00x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 26-27 Extract data along the ROI as new signal profile by “slicing” the signal and plot the profile .. GENERATED FROM PYTHON SOURCE LINES 27-31 .. code-block:: Python profile = line_roi(cl2) profile.plot() .. image-sg:: /auto_examples/plotting/images/sphx_glr_extraction_of_linescan_002.png :alt: cathodoluminescence_example Signal :srcset: /auto_examples/plotting/images/sphx_glr_extraction_of_linescan_002.png, /auto_examples/plotting/images/sphx_glr_extraction_of_linescan_002_5_00x.png 5.00x :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.807 seconds) .. _sphx_glr_download_auto_examples_plotting_extraction_of_linescan.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: extraction_of_linescan.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: extraction_of_linescan.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: extraction_of_linescan.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_