改变 Matplotlib Axes3D.quiver 图中箭头的长度
Vary length of arrows in Matplotlib Axes3D.quiver plot
有什么方法可以改变箭袋图中各个箭头的长度吗?
我使用以下方法创建了一个图:
lines_to_draw = list of numpy 3d vectors
xs, ys, zs = list of coordinates
us, vs, ws = list of displacements
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for line in lines_to_draw:
ax.plot(line[:,0], line[:,1], line[:,2], color='green'
ax.quiver(xs, ys, zs, us, vs, ws)
看起来像这样(轴关闭):
问题是所有的箭头看起来都一样大。文档表明可能是这种情况(特别是 length
参数):
Axes3D.quiver(*args, **kwargs)
Plot a 3D field of arrows.
call signatures:
quiver(X, Y, Z, U, V, W, **kwargs) Arguments:
X, Y, Z: The x, y and z coordinates of the arrow locations
U, V, W: The direction vector that the arrow is pointing The arguments could be
array-like or scalars, so long as they they can be broadcast together.
The arguments can also be masked arrays. If an element in any of
argument is masked, then that corresponding quiver element will not be
plotted.
Keyword arguments:
length: [1.0 | float] The length of each quiver, default to 1.0, the
unit is the same with the axes
arrow_length_ratio: [0.3 | float] The
ratio of the arrow head with respect to the quiver, default to 0.3 Any
additional keyword arguments are delegated to LineCollection
澄清一下,向量的大小相差高达 30 倍。因此应该有非常明显的差异。
在下一个主要的 MPL 版本中将有可能,请参阅此 pull request。
Hack:您可以编辑系统上的相应 MPL 文件,请参阅 答案。
或者:为每个箭头发出单独的 ax.quiver
命令,具有单独的 length
属性。这不是很有效,但在某些情况下这可能已经有所帮助。
有什么方法可以改变箭袋图中各个箭头的长度吗?
我使用以下方法创建了一个图:
lines_to_draw = list of numpy 3d vectors
xs, ys, zs = list of coordinates
us, vs, ws = list of displacements
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for line in lines_to_draw:
ax.plot(line[:,0], line[:,1], line[:,2], color='green'
ax.quiver(xs, ys, zs, us, vs, ws)
看起来像这样(轴关闭):
问题是所有的箭头看起来都一样大。文档表明可能是这种情况(特别是 length
参数):
Axes3D.quiver(*args, **kwargs) Plot a 3D field of arrows.
call signatures:
quiver(X, Y, Z, U, V, W, **kwargs) Arguments:
X, Y, Z: The x, y and z coordinates of the arrow locations
U, V, W: The direction vector that the arrow is pointing The arguments could be array-like or scalars, so long as they they can be broadcast together. The arguments can also be masked arrays. If an element in any of argument is masked, then that corresponding quiver element will not be plotted.
Keyword arguments:
length: [1.0 | float] The length of each quiver, default to 1.0, the unit is the same with the axes
arrow_length_ratio: [0.3 | float] The ratio of the arrow head with respect to the quiver, default to 0.3 Any additional keyword arguments are delegated to LineCollection
澄清一下,向量的大小相差高达 30 倍。因此应该有非常明显的差异。
在下一个主要的 MPL 版本中将有可能,请参阅此 pull request。
Hack:您可以编辑系统上的相应 MPL 文件,请参阅
或者:为每个箭头发出单独的 ax.quiver
命令,具有单独的 length
属性。这不是很有效,但在某些情况下这可能已经有所帮助。