我正在尝试绘制带有三个箭头的箭羽图,分别指向 x、y 和 z 方向,箭头颜色为绿色、红色和蓝色。但不知何故,箭头的线条颜色正确,但箭头部分的颜色错误,我不确定如何解决。以下是我的代码:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.gca(projection='3d')
cols = ['r', 'g', 'b']
quivers = ax.quiver([0,0,0],[0,0,0],[0,0,0],[1,0,0],[0,1,0],[0,0,1], colors=cols)
ax.set_xlim3d([-2.0, 2.0])
ax.set_xlabel('X')
ax.set_ylim3d([-2.0, 2.0])
ax.set_ylabel('Y')
ax.set_zlim3d([-2, 2])
ax.set_zlabel('Z')
plt.show()
quiver
中,如果将颜色列表指定为选项colors=..
,则颜色循环会对所有线段生效,包括箭头的所有部分。 - swatchai