.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/region_of_interest/ROI_navigator.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_ROI_navigator.py: Navigator ROI ============= Use a RectangularROI to take the sum of an area of the navigation space. .. 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.RectangularROI` for the two dimension navigation space: .. GENERATED FROM PYTHON SOURCE LINES 17-19 .. code-block:: Python roi = hs.roi.RectangularROI() .. GENERATED FROM PYTHON SOURCE LINES 20-26 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. By default, the ROI will be added to the navigation or signal. We specify ``recompute_out_event=None`` to avoid redundant computation when changing the ROI .. GENERATED FROM PYTHON SOURCE LINES 26-37 .. code-block:: Python s.plot() s_roi = roi.interactive(s, recompute_out_event=None, color='C1') # We use :py:class:`~.interactive` function to compute the sum over the ROI interactively: roi_sum = hs.interactive(s_roi.sum, recompute_out_event=None) # Choose the second figure as gallery thumbnail: # sphinx_gallery_thumbnail_number = 1 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/region_of_interest/images/sphx_glr_ROI_navigator_001.png :alt: Two Gaussians Navigator :srcset: /auto_examples/region_of_interest/images/sphx_glr_ROI_navigator_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/region_of_interest/images/sphx_glr_ROI_navigator_002.png :alt: Two Gaussians Signal :srcset: /auto_examples/region_of_interest/images/sphx_glr_ROI_navigator_002.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 38-39 Plot the signal sliced by the ROI: .. GENERATED FROM PYTHON SOURCE LINES 39-40 .. code-block:: Python roi_sum.plot() .. image-sg:: /auto_examples/region_of_interest/images/sphx_glr_ROI_navigator_003.png :alt: Two Gaussians Signal :srcset: /auto_examples/region_of_interest/images/sphx_glr_ROI_navigator_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.728 seconds) .. _sphx_glr_download_auto_examples_region_of_interest_ROI_navigator.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ROI_navigator.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ROI_navigator.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_