.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/general/plot_cross_section.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_generated_gallery_general_plot_cross_section.py: Cross Section Plots =================== This example demonstrates contour plots of a cross-sectioned multi-dimensional cube which features a hybrid height vertical coordinate system. .. GENERATED FROM PYTHON SOURCE LINES 9-43 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /generated/gallery/general/images/sphx_glr_plot_cross_section_001.png :alt: Air potential temperature :srcset: /generated/gallery/general/images/sphx_glr_plot_cross_section_001.png :class: sphx-glr-multi-img * .. image-sg:: /generated/gallery/general/images/sphx_glr_plot_cross_section_002.png :alt: Air potential temperature :srcset: /generated/gallery/general/images/sphx_glr_plot_cross_section_002.png :class: sphx-glr-multi-img .. code-block:: Python import matplotlib.pyplot as plt import iris import iris.plot as iplt import iris.quickplot as qplt def main(): # Load some test data. fname = iris.sample_data_path("hybrid_height.nc") theta = iris.load_cube(fname, "air_potential_temperature") # Extract a single height vs longitude cross-section. N.B. This could # easily be changed to extract a specific slice, or even to loop over *all* # cross section slices. cross_section = next(theta.slices(["grid_longitude", "model_level_number"])) qplt.contourf(cross_section, coords=["grid_longitude", "altitude"], cmap="RdBu_r") iplt.show() # Now do the equivalent plot, only against model level plt.figure() qplt.contourf( cross_section, coords=["grid_longitude", "model_level_number"], cmap="RdBu_r", ) iplt.show() if __name__ == "__main__": main() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.333 seconds) .. _sphx_glr_download_generated_gallery_general_plot_cross_section.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_cross_section.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_cross_section.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_