.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/visualization/plot_nice_master_pattern_image.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_examples_visualization_plot_nice_master_pattern_image.py: Plot nice master pattern image ============================== This example shows you how to plot a nice and clean image of an EBSD master pattern. More details are given in the :doc:`visualization tutorial `. .. GENERATED FROM PYTHON SOURCE LINES 9-33 .. image-sg:: /examples/visualization/images/sphx_glr_plot_nice_master_pattern_image_001.png :alt: Upper, Lower :srcset: /examples/visualization/images/sphx_glr_plot_nice_master_pattern_image_001.png :class: sphx-glr-single-img .. code-block:: default import kikuchipy as kp import matplotlib.pyplot as plt import numpy as np # Load both hemispheres of master pattern in stereographic projection mp = kp.data.nickel_ebsd_master_pattern_small(hemisphere="both") # Extract the underlying data of both hemipsheres and mask out the # surrounding black pixels data = mp.data.astype("float32") mask = data[0] == 0 data[:, mask] = np.nan # Plot both hemispheres with labels fig, (ax0, ax1) = plt.subplots(ncols=2) ax0.imshow(data[0], cmap="gray") ax1.imshow(data[1], cmap="gray") ax0.axis("off") ax1.axis("off") ax0.set_title("Upper") ax1.set_title("Lower") fig.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.606 seconds) **Estimated memory usage:** 9 MB .. _sphx_glr_download_examples_visualization_plot_nice_master_pattern_image.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_nice_master_pattern_image.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_nice_master_pattern_image.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_