2017-06-26 30 views
1

我试图从matplotlib使用quiver来绘制向量(3,2)和(4,-1)。然而,下面的代码Matplotlib颤抖与否定的方向

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)矢量是正确的。发生了什么事以及如何解决它?

回答

1

当我在我的系统上运行代码时(在Spyder 3.1.4中使用matplotlib 2.0.2在IPython 5.3.0控制台或Python控制台上运行的所有Windows 10创作者更新)我都没有得到你展示的图表。我得到

enter image description here

这是你在找什么,我相信。你可能有一个版本的matplotlib或其他有bug的软件。尝试升级到最新版本并重试。

+0

Matplotlib v。2.0.0修正了它。谢谢! – bcf