2013-12-14 103 views
3

我在繪製numpy數組/矩陣時遇到了麻煩。我定義了一個如下的隨機數矩陣:如何繪製/分散矩陣的列

g1 = matrix([[x,y] for x,y in zip(rand(40),rand(40)) if ((x>0.5 and y>0.5) or (x<0.5 and y<0.5))]) 

這就創建了合適的矩陣。現在我想分散這種矩陣elemnts:

scatter(g1[:,1],g1[:,0]) 

失敗,出現錯誤:maximum recursion depth exceeded

看來問題是一個事實,即列g1[:,1]仍然是一個矩陣引起的。因爲如果我繪製:

plot(array(g1[:,1]),array(g1[:,0])) 

這是行得通的。 我很困惑,如何直觀和簡單的事情,如繪製一個矩陣列彼此是複雜的。難道我做錯了什麼?

+1

'散射(g1 [:,1],g1 [:,0])'適合我 - Python 3.3,matplotlib 1.3.0,numpy 1.8.0 ... – MattDMo

+0

這是一個已知的bug https://github.com/matplotlib/matplotlib/pull/2290 – tacaswell

+0

非常有趣 - 我剛剛安裝了matplotlib 1.3.1,並得到遞歸錯誤... – MattDMo

回答