2013-12-14 76 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

回答