.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "intro/matplotlib/auto_examples/pretty_plots/plot_plot3d_ext.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_intro_matplotlib_auto_examples_pretty_plots_plot_plot3d_ext.py: 3D plotting vignette ===================== Demo 3D plotting with matplotlib and decorate the figure. .. GENERATED FROM PYTHON SOURCE LINES 7-51 .. image-sg:: /intro/matplotlib/auto_examples/pretty_plots/images/sphx_glr_plot_plot3d_ext_001.png :alt: plot plot3d ext :srcset: /intro/matplotlib/auto_examples/pretty_plots/images/sphx_glr_plot_plot3d_ext_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 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) fig = plt.figure() ax: Axes3D = fig.add_subplot(111, projection="3d") 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.xticks([]) plt.yticks([]) ax.set_zticks([]) ax.text2D( 0.05, 0.93, " 3D plots \n", horizontalalignment="left", verticalalignment="top", size="xx-large", bbox={"facecolor": "white", "alpha": 1.0}, transform=plt.gca().transAxes, ) ax.text2D( 0.05, 0.87, " Plot 2D or 3D data", horizontalalignment="left", verticalalignment="top", size="large", transform=plt.gca().transAxes, ) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.096 seconds) .. _sphx_glr_download_intro_matplotlib_auto_examples_pretty_plots_plot_plot3d_ext.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_ext.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_plot3d_ext.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_plot3d_ext.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_