Matplotlib代码:
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import style
style.use('fivethirtyeight')
fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')
x = [1,2,3,4,5,6,7,8,9,10]
y = [5,6,7,8,2,5,6,3,7,2]
z = [1,2,6,3,2,7,3,3,7,2]
ax1.plot_wireframe(x,y,z)
ax1.set_xlabel('x axis')
ax1.set_ylabel('y axis')
ax1.set_zlabel('z axis')
plt.show()错误输出:

预期产出:

发布于 2021-08-18 04:56:00
目前您的数据是一维列表,但是plot_wireframe需要2D数组:
参数:
X,Y,Z:2D数组
因此,转换一维列表-> 2D列表-> 2D数组,例如x -> [x] -> np.array([x])
ax1.plot_wireframe(np.array([x]), np.array([y]), np.array([z]))

https://stackoverflow.com/questions/68826455
复制相似问题