Matplotlib question-- Numeric or numarray?
John Hunter
jdhunter at ace.bsd.uchicago.edu
Fri Apr 8 10:17:19 EDT 2005
>>>>> "Matt" == Matt Feinstein <nospam at here.com> writes:
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
More information about the Python-list
mailing list