注意
前往結尾以下載完整範例程式碼。
3D 曲面(實色)#
示範使用實色繪製 3D 曲面的基本繪圖。
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
# Make data
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = 10 * np.outer(np.cos(u), np.sin(v))
y = 10 * np.outer(np.sin(u), np.sin(v))
z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
# Plot the surface
ax.plot_surface(x, y, z)
# Set an equal aspect ratio
ax.set_aspect('equal')
plt.show()

腳本的總執行時間:(0 分鐘 2.033 秒)