.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "intro/matplotlib/auto_examples/plot_plot3d.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end <sphx_glr_download_intro_matplotlib_auto_examples_plot_plot3d.py>` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_intro_matplotlib_auto_examples_plot_plot3d.py: 3D plotting =========== A simple example of 3D plotting. .. GENERATED FROM PYTHON SOURCE LINES 7-24 .. image-sg:: /intro/matplotlib/auto_examples/images/sphx_glr_plot_plot3d_001.png :alt: plot plot3d :srcset: /intro/matplotlib/auto_examples/images/sphx_glr_plot_plot3d_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D ax: Axes3D = plt.figure().add_subplot(projection="3d") x = np.arange(-4, 4, 0.25) y = np.arange(-4, 4, 0.25) X, Y = np.meshgrid(x, y) R = np.sqrt(X**2 + Y**2) Z = np.sin(R) ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap="hot") ax.contourf(X, Y, Z, zdir="z", offset=-2, cmap="hot") ax.set_zlim(-2, 2) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.134 seconds) .. _sphx_glr_download_intro_matplotlib_auto_examples_plot_plot3d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_plot3d.ipynb <plot_plot3d.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_plot3d.py <plot_plot3d.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_plot3d.zip <plot_plot3d.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_