.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/region_of_interest/SpanROI.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_region_of_interest_SpanROI.py: SpanROI on signal axis ====================== Use a SpanROI interactively on a Signal1D. .. GENERATED FROM PYTHON SOURCE LINES 8-11 .. code-block:: Python import hyperspy.api as hs .. GENERATED FROM PYTHON SOURCE LINES 12-13 Create a signal: .. GENERATED FROM PYTHON SOURCE LINES 13-15 .. code-block:: Python s = hs.data.two_gaussians() .. GENERATED FROM PYTHON SOURCE LINES 16-17 Create the roi, here a :py:class:`~.api.roi.SpanROI` for one dimensional ROI: .. GENERATED FROM PYTHON SOURCE LINES 17-19 .. code-block:: Python roi = hs.roi.SpanROI(left=10, right=20) .. GENERATED FROM PYTHON SOURCE LINES 20-25 Slice signal with roi with the ROI. By using the `interactive` function, the output signal ``s_roi`` will update automatically. The ROI will be added automatically on the signal figure. Specify the ``axes`` to add the ROI on either the navigation or signal dimension: .. GENERATED FROM PYTHON SOURCE LINES 25-31 .. code-block:: Python s.plot() sliced_signal = roi.interactive(s, axes=s.axes_manager.signal_axes) # Choose the second figure as gallery thumbnail: # sphinx_gallery_thumbnail_number = 2 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/region_of_interest/images/sphx_glr_SpanROI_001.png :alt: Two Gaussians Navigator :srcset: /auto_examples/region_of_interest/images/sphx_glr_SpanROI_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/region_of_interest/images/sphx_glr_SpanROI_002.png :alt: Two Gaussians Signal :srcset: /auto_examples/region_of_interest/images/sphx_glr_SpanROI_002.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 32-34 Plot the signal sliced by the ROI and use ``autoscale='xv'`` to update the limits of the plot automatically: .. GENERATED FROM PYTHON SOURCE LINES 34-35 .. code-block:: Python sliced_signal.plot(autoscale='xv') .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/region_of_interest/images/sphx_glr_SpanROI_003.png :alt: Two Gaussians Navigator :srcset: /auto_examples/region_of_interest/images/sphx_glr_SpanROI_003.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/region_of_interest/images/sphx_glr_SpanROI_004.png :alt: Two Gaussians Signal :srcset: /auto_examples/region_of_interest/images/sphx_glr_SpanROI_004.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.263 seconds) .. _sphx_glr_download_auto_examples_region_of_interest_SpanROI.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: SpanROI.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: SpanROI.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_