Problem with numpy in matplotlib

Hi,

I have switched to numpy (I was using numarray before) with matplotlib.

I have now however a problem when doing for example:

x = numpy.core.multiarray.arange(0.,6.,1.)
y = numpy.core.multiarray.arange(0.,6.,1.)
clos = numpy.core.multiarray.arange(0.,1.,.1)
scatter(x,y,c=clos)

I get:
.................
/usr/lib/python2.4/site-packages/matplotlib/numerix/__init__.py in typecode(a)
     89 # so assume numpy.
     90 def typecode(a):
---> 91 return a.dtypechar
     92 def iscontiguous(a):
     93 return a.flags.contiguous

AttributeError: 'numpy.ndarray' object has no attribute 'dtypechar'

ONE OTHER question:

- is it possible when using "scatter" to have the specified color (c=...) projected on the present colormap like when using an array of colors, instead of just having levels of grey? I have N points that I wish to plot but all with the same color which I wish to specify by a simple number between e.g. 0 and 1 corresponding to my colormap.

thanks
Eric

···

--

===============================================================
Observatoire de Lyon emsellem@...419...
9 av. Charles-Andre tel: +33 4 78 86 83 84
69561 Saint-Genis Laval Cedex fax: +33 4 78 86 83 86
France http://www-obs.univ-lyon1.fr/eric.emsellem

This reflects a recent change in numpy. Try updating your MPL from cvs, it
should be fixed there.

Darren

···

On Thursday 19 January 2006 07:49, Eric Emsellem wrote:

Hi,

I have switched to numpy (I was using numarray before) with matplotlib.

I have now however a problem when doing for example:

x = numpy.core.multiarray.arange(0.,6.,1.)
y = numpy.core.multiarray.arange(0.,6.,1.)
clos = numpy.core.multiarray.arange(0.,1.,.1)
scatter(x,y,c=clos)

I get:
.................
/usr/lib/python2.4/site-packages/matplotlib/numerix/__init__.py in
typecode(a)
89 # so assume numpy.
90 def typecode(a):
---> 91 return a.dtypechar
92 def iscontiguous(a):
93 return a.flags.contiguous

AttributeError: 'numpy.ndarray' object has no attribute 'dtypechar'

Eric Emsellem wrote:

I have switched to numpy (I was using numarray before) with matplotlib.

x = numpy.core.multiarray.arange(0.,6.,1.)

Why not use:

x = numpy.arange(0.,6.,1.)

Or maybe better with MPL:

import matplotlib.numerix as nx
x = nx.arange(0.,6.,1.)

after setting numerix appropriately in .matplotlibrc.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

I agree. numpy.core.multiarray is the base object for arrays, but it
not really supposed to be used directly. All arrays should have a
dtypechar property, and since that was the source of your original
error, I am even more sure you shouldn't use it directly. Chris's
suggestions are the correct approach.

···

On 1/19/06, Christopher Barker <Chris.Barker@...259...> wrote:

Eric Emsellem wrote:

> I have switched to numpy (I was using numarray before) with matplotlib.

> x = numpy.core.multiarray.arange(0.,6.,1.)

Why not use:

x = numpy.arange(0.,6.,1.)

Or maybe better with MPL:

import matplotlib.numerix as nx
x = nx.arange(0.,6.,1.)

after setting numerix appropriately in .matplotlibrc.

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Charlie Moad wrote:

I agree. numpy.core.multiarray is the base object for arrays, but it
not really supposed to be used directly. All arrays should have a
dtypechar property, and since that was the source of your original
error, I am even more sure you shouldn't use it directly.

As Darren noted, A.dtypechar was recently changed to A.dtype.char in numpy, and
matplotlib in CVS now reflects that change.

···

--
Robert Kern
robert.kern@...287...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
  -- Richard Harter

Ok thanks. (in fact the cvs version seemed to have solved it for some reason)

I did that only because when doing "help(arange)" it gave me that dependency and
I wanted to be sure to use the right one here. So why is Ipython giving me that
instead of the most direct one?

thanks again
Eric

···

I agree. numpy.core.multiarray is the base object for arrays, but it
not really supposed to be used directly. All arrays should have a
dtypechar property, and since that was the source of your original
error, I am even more sure you shouldn't use it directly. Chris's
suggestions are the correct approach.

On 1/19/06, Christopher Barker <Chris.Barker@...259...> wrote:
> Eric Emsellem wrote:
>
> > I have switched to numpy (I was using numarray before) with matplotlib.
>
> > x = numpy.core.multiarray.arange(0.,6.,1.)
>
> Why not use:
>
> x = numpy.arange(0.,6.,1.)
>
> Or maybe better with MPL:
>
> import matplotlib.numerix as nx
> x = nx.arange(0.,6.,1.)
>
> after setting numerix appropriately in .matplotlibrc.
>
> -Chris
>
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> NOAA/OR&R/HAZMAT (206) 526-6959 voice
> 7600 Sand Point Way NE (206) 526-6329 fax
> Seattle, WA 98115 (206) 526-6317 main reception
>
> Chris.Barker@...259...
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> matplotlib-users List Signup and Options
>

--

--------------------------------------------------------------------------
Ce message a �t� envoy� depuis le webmail IMP (Internet Messaging Program)

Eric Emsellem wrote:

Ok thanks. (in fact the cvs version seemed to have solved it for some reason)

I did that only because when doing "help(arange)" it gave me that dependency and
I wanted to be sure to use the right one here. So why is Ipython giving me that
instead of the most direct one?

Because IPython doesn't read mailing lists or manuals :slight_smile: It only shows what the inspect.get* routines return, and that's where arange _lives_ at the internal, implementation level. IPython tries really, really hard to make your life easy, but there's a limit to its powers :slight_smile:

Cheers,

f

Eric Emsellem wrote:

Ok thanks. (in fact the cvs version seemed to have solved it for some reason)

I did that only because when doing "help(arange)" it gave me that dependency and
I wanted to be sure to use the right one here. So why is Ipython giving me that
instead of the most direct one?

arange is defined in the module numpy.core.multiarray. That information is
stored in the builtin_function_or_method object itself. It can't know that it is
being imported into the root numpy namespace or anywhere else. Consequently, the
help() function can't know that you are accessing it as "from numpy import *;
help(arange)", and only gives you the information that it knows.

···

--
Robert Kern
robert.kern@...287...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
  -- Richard Harter