Matplotlib question-- Numeric or numarray?

M

Matt Feinstein

I'm working my way through the matplotlib documentation & there's a
point that's ambiguous-- the pdf file (dated Mar. 1, 2005) warns of
dire consequences if I use the 'wrong' array package-- e.g., put
numarray in the .matlabrc file if the compile-time package is Numeric.
But there's only one current, unlabeled, windows installer and there
seems to have been a change, some time back before version 0.7, in how
this question is dealt with. Can someone clarify?
thnksndvnc

Matt Feinstein
 
J

John Hunter

Matt> I'm working my way through the matplotlib documentation &
Matt> there's a point that's ambiguous-- the pdf file (dated
Matt> Mar. 1, 2005) warns of dire consequences if I use the
Matt> 'wrong' array package-- e.g., put numarray in the .matlabrc
Matt> file if the compile-time package is Numeric. But there's
Matt> only one current, unlabeled, windows installer and there
Matt> seems to have been a change, some time back before version
Matt> 0.7, in how this question is dealt with. Can someone
Matt> clarify? thnksndvnc

Hi Matt -- it looks like the documentation is out of data. matplotlib
can now be built to support Numeric and numarray simultaneously, and
which one you are using is controlled at runtime by the numerix
setting in your rc file. The windows installers now have support for
both Numeric and numarray built in.

I recommend you use the matplotlib.numerix module to import your
Numeric/numarray symbols in matplotlib scripts, rather than using
Numeric/numarray directly. The reason is that it is still important
that the arrays you create match the type in your rc file, and the
numerix module insures that this happens.

One good way to do this is

import matplotlib.numerix as nx
a = nx.array(blah)


The matplotlib numerix package structure mirros numarray. Eg to
import mean, you would do

from matplotlib.numerix.mlab import mean

which in numarray is located in numarray.mlab and in Numeric is in
MLab.

If trying to figure out where all the various numerix functions live
makes your head hurt, you can use the pylab module which aggregates
all the numerix and plotting functions into a single namespace

import pylab as p

a = p.array([1,2,3])
n = p.randn(10000)
mu, sigma = p.mean(n), p.std(n)

p.hist(n, 1000)

p.show()


Hope this helps,
JDH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top