注意
前往結尾下載完整範例程式碼。
填充 3D 線條之間#
示範如何使用曲面填充 3D 線條之間的空間。這裡我們建立一種「燈罩」形狀。
import matplotlib.pyplot as plt
import numpy as np
N = 50
theta = np.linspace(0, 2*np.pi, N)
x1 = np.cos(theta)
y1 = np.sin(theta)
z1 = 0.1 * np.sin(6 * theta)
x2 = 0.6 * np.cos(theta)
y2 = 0.6 * np.sin(theta)
z2 = 2 # Note that scalar values work in addition to length N arrays
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
ax.fill_between(x1, y1, z1, x2, y2, z2, alpha=0.5, edgecolor='k')
plt.show()

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