from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(15,8),dpi=100)
ax = fig.add_subplot(111, projection='3d')
x=np.array([[-30, -20, -10, 0, 10, 20,],
[-30, -20, -10, 0, 10, 20,],
[-30, -20, -10, 0, 10, 20,],
[-30, -20, -10, 0, 10, 20,],
[-30, -20, -10, 0, 10, 20,],
[-30, -20, -10, 0, 10, 20,]])
y=np.array([[-30, -30, -30, -30, -30, -30,],
[-20, -20, -20, -20, -20, -20,],
[-10, -10, -10, -10, -10, -10,],
[ 0, 0, 0, 0, 0, 0,],
[ 10, 10, 10, 10, 10, 10,],
[ 20, 20, 20, 20, 20, 20,]])
z=np.array([[ 0, 1, 2, 3, 4, 5],
[ 0, 1, 2, 3, 4, 5],
[ 0, 1, 2, 3, 4, 5],
[ 0, 1, 2, 3, 4, 5],
[ 0, 1, 2, 3, 4, 5],
[ 0, 1, 2, 3, 4, 5]])
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.plot_wireframe(x, y, z, rstride=1, cstride=1)
#转换视角
ax.view_init(elev=45,azim=-75)
plt.show()
感谢:
https://www.matplotlib.org.cn/gallery/mplot3d/wire3d.html
