gpt4 book ai didi

python - 带负方向的 Matplotlib Quiver

转载 作者:太空宇宙 更新时间:2023-11-03 15:04:51 26 4
gpt4 key购买 nike

我正在尝试使用 matplotlib 中的 quiver 绘制向量 (3,2) 和 (4,-1)。但是,下面的代码

import matplotlib.pyplot as plt

X = (0, 0)
Y = (0, 0)
U = (3, 4)
V = (2, -1)

fig, ax = plt.subplots()
ax.quiver( X, Y, U, V, angles='xy', scale_units='xy', scale=1 )
ax.set_xlim( [ -5, 5 ] )
ax.set_ylim( [ -5, 5 ] )
plt.show()

生成以下图: vectors

(4,-1) 向量绘制为 (-4,-1),但 (3,2) 向量是正确的。这是怎么回事,如何解决?

最佳答案

当我在我的系统上运行您的代码时(Spyder 3.1.4 中的 Python 3.6.1,在 IPython 5.3.0 控制台或全部在 Windows 10 Creators Update 上运行的 Python 控制台中使用 matplotlib 2.0.2),我没有得到您显示的图表。我明白

enter image description here

我相信这就是您正在寻找的。您的 matplotlib 版本或其他软件可能存在错误。尝试升级到最新版本并重试。

关于python - 带负方向的 Matplotlib Quiver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44762494/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com