matplotlib:改变轴方向
matplotlib: change axis orientation
我使用 matplotlib 绘制了一个 3d 图形
def showlab(dic, title):
global driehoeken
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
lijst = np.array(driehoeken)
lijst = np.around(lijst, 2)
poly3d = [[lijst[i, j*3:j*3+3]for j in range(3)]for i in range(lijst.shape[0])]
ax.add_collection3d(Poly3DCollection(poly3d, linewidth = 1))
ax.set_xlim(0, 100)
ax.set_xlabel('l')
ax.set_ylim(-150, 150)
ax.set_ylabel('a')
ax.set_zlim(-150, 150)
ax.set_zlabel('b')
plt.title(title)
plt.show()
此图绘制了一个 'b' 轴朝上的图形。但我想让 'l' 轴指向上方,但保持右手法则。有没有简单的方法可以做到这一点?
您只需按正确的顺序设置限制即可反转轴:
ax.set_xlib(100, 0)
Whosebug 中也有类似的问题:Reverse Y-axis in PyPlot
我使用 matplotlib 绘制了一个 3d 图形
def showlab(dic, title):
global driehoeken
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
lijst = np.array(driehoeken)
lijst = np.around(lijst, 2)
poly3d = [[lijst[i, j*3:j*3+3]for j in range(3)]for i in range(lijst.shape[0])]
ax.add_collection3d(Poly3DCollection(poly3d, linewidth = 1))
ax.set_xlim(0, 100)
ax.set_xlabel('l')
ax.set_ylim(-150, 150)
ax.set_ylabel('a')
ax.set_zlim(-150, 150)
ax.set_zlabel('b')
plt.title(title)
plt.show()
此图绘制了一个 'b' 轴朝上的图形。但我想让 'l' 轴指向上方,但保持右手法则。有没有简单的方法可以做到这一点?
您只需按正确的顺序设置限制即可反转轴:
ax.set_xlib(100, 0)
Whosebug 中也有类似的问题:Reverse Y-axis in PyPlot