matplotlib 3D线条图箭头传参失败

2024-09-29 02:17:11 发布

您现在位置:Python中文网/ 问答频道 /正文

为什么会产生错误?夸格支点斧箭导致代码失败,但它在没有kwarg的情况下也能工作。错误消息也不是很有用。我使用的是python3.4和matplotlib 1.4.3。谢谢。在

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()

ax = plt.axes(projection='3d')

x=[0,0,4,4]
y=[0,5,5,5]
z=[0,0,0,-2]

ax.plot(x, y, z, '-b', linewidth=5)
ax.view_init(30, 30)

ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')

X=[0]
Y=[5]
Z=[0]
U=[-60]
V=[40]
W=[20]

ax.quiver3D(X, Y, Z, U, V, W, pivot='tail')

错误信息

^{pr2}$

Tags: 代码fromimport消息matplotlibas错误情况
1条回答
网友
1楼 · 发布于 2024-09-29 02:17:11

您需要更新matplotlib。在

documentation of version 1.5.0(第641页):

quiver3D(*args, **kwargs)

Plot a 3D field of arrows.

...

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

pivot: [ ‘tail’ | ‘middle’ | ‘tip’ ] The part of the arrow that is at the grid point; the arrow rotates about this point, hence the name pivot.

Any additional keyword arguments are delegated to LineCollection

documentation of version 1.4.3(第567页)中也是如此:

quiver3D(*args, **kwargs)

Plot a 3D field of arrows.

...

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

这个特性只是在1.4.3中缺失了,这也解释了为什么没有一条信息性的错误消息:pivot关键字被传递给LineCollection,而这对它没有任何意义。在

相关问题 更多 >