errors when plotting random vectors

hi all,

i’m trying to do something extremely simple, namely print a scatter plot of two random arrays:

import matplotlib.plt as plt
from numpy.random import *

x = rand(1,10)
scatter(x, x)

this fails with the error:

ValueError: Offsets array must be Nx2

what is happening here? are arrays somehow weird? do they not behave like lists? any info on this will be greatly appreciated.

thank you.

per freem wrote:

hi all,

i'm trying to do something extremely simple, namely print a scatter plot of two random arrays:

import matplotlib.plt as plt
from numpy.random import *

x = rand(1,10)
scatter(x, x)

this fails with the error:

ValueError: Offsets array must be Nx2

what is happening here? are arrays somehow weird? do they not behave like lists? any info on this will be greatly appreciated.

Your "x" is 2-D; what you want is rand(10); or you can do scatter(x.ravel(), x.ravel()).

Your example does point to a bug in scatter, however; it should not be failing with an obscure error message like that. (In mpl from svn trunk it still fails, but with a different obscure error message.) I don't know any good reason why it should not be able to handle the 2-D inputs. I will take a look.

Eric

···

thank you.

------------------------------------------------------------------------

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H

------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options