.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/mplot3d/surface3d_radial.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. 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_gallery_mplot3d_surface3d_radial.py: ================================= 3D surface with polar coordinates ================================= Demonstrates plotting a surface defined in polar coordinates. Uses the reversed version of the YlGnBu colormap. Also demonstrates writing axis labels with latex math mode. Example contributed by Armin Moser. .. GENERATED FROM PYTHON SOURCE LINES 12-38 .. image-sg:: /gallery/mplot3d/images/sphx_glr_surface3d_radial_001.png :alt: surface3d radial :srcset: /gallery/mplot3d/images/sphx_glr_surface3d_radial_001.png, /gallery/mplot3d/images/sphx_glr_surface3d_radial_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(projection='3d') # Create the mesh in polar coordinates and compute corresponding Z. r = np.linspace(0, 1.25, 50) p = np.linspace(0, 2*np.pi, 50) R, P = np.meshgrid(r, p) Z = ((R**2 - 1)**2) # Express the mesh in the cartesian system. X, Y = R*np.cos(P), R*np.sin(P) # Plot the surface. ax.plot_surface(X, Y, Z, cmap=plt.cm.YlGnBu_r) # Tweak the limits and add latex math labels. ax.set_zlim(0, 1) ax.set_xlabel(r'$\phi_\mathrm{real}$') ax.set_ylabel(r'$\phi_\mathrm{im}$') ax.set_zlabel(r'$V(\phi)$') plt.show() .. _sphx_glr_download_gallery_mplot3d_surface3d_radial.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: surface3d_radial.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: surface3d_radial.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_