.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/data_visualization/specifying_ax.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_data_visualization_specifying_ax.py: Specifying Matplotlib Axis ========================== .. GENERATED FROM PYTHON SOURCE LINES 8-12 .. code-block:: Python import hyperspy.api as hs import matplotlib.pyplot as plt import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 13-17 Signal2D -------- Create two Signal2D .. GENERATED FROM PYTHON SOURCE LINES 20-23 .. code-block:: Python s = hs.signals.Signal2D(np.arange(100).reshape(10, 10)) s2 = -s .. GENERATED FROM PYTHON SOURCE LINES 24-27 Create a list of :external+matplotlib:class:`matplotlib.axis.Axis` using :external+matplotlib:func:`matplotlib.pyplot.subplots` and specify the second matplotlib axis of the list to :func:`~.api.plot.plot_images` .. GENERATED FROM PYTHON SOURCE LINES 27-31 .. code-block:: Python fig, axs = plt.subplots(ncols=3, nrows=1) hs.plot.plot_images(s, ax=axs[1], axes_decor="off") .. image-sg:: /auto_examples/data_visualization/images/sphx_glr_specifying_ax_001.png :alt: () :srcset: /auto_examples/data_visualization/images/sphx_glr_specifying_ax_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [] .. GENERATED FROM PYTHON SOURCE LINES 32-33 The same can be done for a list of signals and axis .. GENERATED FROM PYTHON SOURCE LINES 33-37 .. code-block:: Python fig, axs = plt.subplots(ncols=3, nrows=1) hs.plot.plot_images([s, s2], ax=axs[1:3], axes_decor="off") .. image-sg:: /auto_examples/data_visualization/images/sphx_glr_specifying_ax_002.png :alt: specifying ax :srcset: /auto_examples/data_visualization/images/sphx_glr_specifying_ax_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [, ] .. GENERATED FROM PYTHON SOURCE LINES 38-44 Signal1D -------- The same can be for :class:`~.api.signals.Signal1D` Create two Signal2D .. GENERATED FROM PYTHON SOURCE LINES 47-50 .. code-block:: Python s = hs.signals.Signal1D(np.arange(100)) s2 = -s .. GENERATED FROM PYTHON SOURCE LINES 51-54 Create an array of :external+matplotlib:class:`matplotlib.axis.Axis` using :external+matplotlib:func:`matplotlib.pyplot.subplots` and specify the two las matplotlib axis of the second line to :func:`~.api.plot.plot_spectra` .. GENERATED FROM PYTHON SOURCE LINES 56-58 .. code-block:: Python fig, axs = plt.subplots(ncols=3, nrows=2) hs.plot.plot_spectra([s, s2], ax=axs[1, 1:3], style="mosaic") .. image-sg:: /auto_examples/data_visualization/images/sphx_glr_specifying_ax_003.png :alt: specifying ax :srcset: /auto_examples/data_visualization/images/sphx_glr_specifying_ax_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none array([, ], dtype=object) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.855 seconds) .. _sphx_glr_download_auto_examples_data_visualization_specifying_ax.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: specifying_ax.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: specifying_ax.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: specifying_ax.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_