带极坐标的 3D 曲面#

演示了如何在极坐标系中绘制曲面。使用 YlGnBu 颜色图的反转版本。还演示了如何使用 LaTeX 数学模式编写轴标签。

示例由 Armin Moser 贡献。

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()
surface3d radial

标签:绘图类型:3D 绘图类型:极坐标 级别:初学者

脚本总运行时间:(0 分钟 1.869 秒)

由 Sphinx-Gallery 生成的画廊