LJulien Rebetez : > I've run into a strange behaviour of matplotlib while trying to figure > out why my data was displayed incorrectly. > I'm note quite sure if this is a bug or expected behaviour, but I feel > it's kind of counter-intuitive, so I'm posting here. > > ... > Now there seem to be a difference on how numpy handles A[:,0] > depending on if A is a np.array or np.matrix. In the case of > an array, a 1D array is returned, in the case of a matrix, a 2D Nx1 > matrix is returned. Using this matrix seems to confuse matplotlib. > > Using np.ravel or np.flatten on the slices fix that problem. > > Is there an explanation for this behaviour or should I fill a bug ? Don't fill a bug. Read http://www.scipy.org/Tentative_NumPy_Tutorial , please. They explain that a slice of a matrix is a matrix, and its "view" is different from what you get for arrays.
But, no need to reshape the stuff. Just use the "array attribute" of the matrix : pl.scatter(B.A[:,0], B.A[:,1], c='b') //Here 'A' is the name of the attribute, nothing to do with your array A; by chance it is the same...// The best Jerzy Karczmarczuk ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
