2015-01-20 164 views
0

我有一组坐标对(x,y),我想用quiver来绘制这个组。我试图检查其他相关问题,但我仍然在为此而苦苦挣扎。使用颤抖来绘制2D矢量地图

想象我想绘制4个向量与两个数组与x和y坐标:

x = arange(0, 3) 
y = arange(0, 3) 

# vectors x coordinate values 
fx = (0, 1, 1, 2)  
# vectors y coordinate values 
fy = (1, 0, 1, 2) 

X, Y = meshgrid(x, y) 
Q = quiver(X, Y, fx, fy) 

结果不是4,但9载体,为什么呢?

+0

为什么你标记信号处理?这个问题实际上是否适用于这个领域?只是要求好奇 – 2015-01-20 19:35:20

+0

你还需要填写你的fx和fy。有形状需要匹配X,Y的形状。 – tacaswell 2015-01-22 05:57:55

回答

0

您可以通过4个1 d阵列plt.quiver

import numpy as np 
import matplotlib.pyplot as plt 

x = np.arange(0, 4) 
y = np.arange(0, 4) 

# vectors x coordinate values 
fx = (0, 1, 1, 2)  
# vectors y coordinate values 
fy = (1, 0, 1, 2) 


Q = plt.quiver(x, y, fx, fy) 
plt.xlim(-1, 4) 
plt.ylim(-1, 4) 

plt.show() 

产生

enter image description here

+0

非常感谢您的帮助。我期望的最终结果将是将这些矢量绘制成“方形”而不是对角线。基本上,arange会给我2D地图的原点坐标。 – dudas 2015-01-20 20:07:37

+0

谢谢,我认为它工作! – dudas 2015-01-20 20:31:40