.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plotting/chromatic_imaging.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_chromatic_imaging.py: Chromatic Imaging ================= This example shows how to plot color-filtered (chromatic) images from a hyperspectral dataset. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Load the data .. GENERATED FROM PYTHON SOURCE LINES 10-17 .. code-block:: Python import lumispy as lum import hyperspy.api as hs cl1 = lum.data.nanoparticles() cl1.mean().plot() .. image-sg:: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_001.png :alt: cathodoluminescence_example Signal :srcset: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_001.png, /auto_examples/plotting/images/sphx_glr_chromatic_imaging_001_5_00x.png 5.00x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 18-22 First, lets plot the panchromatic (integrated over wavelength axis) image (the object is transposed, so that we plot the intensity over navigation instead of signal dimensions). The parameter 'cmap' specifies the colormap to use for plotting. See :doc:`mpl:users/explain/colors/colormaps`. .. GENERATED FROM PYTHON SOURCE LINES 22-25 .. code-block:: Python cl1.T.mean().plot(cmap="viridis") .. image-sg:: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_002.png :alt: cathodoluminescence_example Signal :srcset: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_002.png, /auto_examples/plotting/images/sphx_glr_chromatic_imaging_002_5_00x.png 5.00x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 26-27 Now, we can plot the intensity in a selected spectral window (color-filtered image) using signal indexing .. GENERATED FROM PYTHON SOURCE LINES 27-30 .. code-block:: Python cl1.isig[480.0:550.0].T.mean().plot(cmap="viridis") .. image-sg:: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_003.png :alt: cathodoluminescence_example Signal :srcset: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_003.png, /auto_examples/plotting/images/sphx_glr_chromatic_imaging_003_5_00x.png 5.00x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 31-32 This spectral filtering can also be done interactively using :py:func:`hyperspy.api.plot.plot_roi_map`. Note that instead of passing explicit ``SpanROI`` objects, the parameter ``rois`` can also take an integer number, for which the corresponding number of ROIs will be initialized with default values for interactive adaptataion: .. GENERATED FROM PYTHON SOURCE LINES 32-36 .. code-block:: Python roi1 = hs.roi.SpanROI(left=480.0, right=550.0) hs.plot.plot_roi_map(signal=cl1, rois=roi1, cmap="viridis") .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_004.png :alt: cathodoluminescence_example Navigator :srcset: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_004.png, /auto_examples/plotting/images/sphx_glr_chromatic_imaging_004_5_00x.png 5.00x :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_005.png :alt: cathodoluminescence_example Signal :srcset: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_005.png, /auto_examples/plotting/images/sphx_glr_chromatic_imaging_005_5_00x.png 5.00x :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_006.png :alt: Integrated intensity Signal :srcset: /auto_examples/plotting/images/sphx_glr_chromatic_imaging_006.png, /auto_examples/plotting/images/sphx_glr_chromatic_imaging_006_5_00x.png 5.00x :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none ([SpanROI(left=480, right=550)], []) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 5.622 seconds) .. _sphx_glr_download_auto_examples_plotting_chromatic_imaging.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: chromatic_imaging.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: chromatic_imaging.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: chromatic_imaging.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_