2015-01-20 167 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