【发布时间】:2015-11-05 08:52:18
【问题描述】:
我想用matplotlib 将曲面绘制成立方体。我正在尝试使用ax.plot_surface(X, Y, Z),但是我有点困惑。 X、Y 和 Z 应该代表什么二维数组?
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
points = np.array([[-1, -1, -1],
[1, -1, -1 ],
[1, 1, -1],
[-1, 1, -1],
[-1, -1, 1],
[1, -1, 1 ],
[1, 1, 1],
[-1, 1, 1]])
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# ax.plot_surface(X, Y, Z) # how?
ax.scatter3D(points[:, 0], points[:, 1], points[:, 2])
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
【问题讨论】:
标签: python matplotlib