-2
我想用常規步進點繪製立方體。如何使用python中的Matplotlib繪製常規步驟點的立方體
我寫了一個函數來做到這一點:
def buildCube(self, x_center, y_center, z_center, step, cote):
x = []
y = []
z = []
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for i in range(-cote/2, cote/2, step):
for j in range(-cote/2, cote/2, step):
for k in range(-cote/2, cote/2, step):
z.append(k + z_center)
y.append(j + y_center)
x.append(i + x_center)
ax.scatter(x, x, z, s=8, c="g", depthshade=True)
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
ax.set_title("Le cube")
plt.show()
但預期這是行不通的。我得到了結果波紋管(我得到了一個方塊,而不是一個立方體)。
謝謝。有用 –