On 2012/10/13 6:41 PM, lulu wrote: > oh brother -- so now I've got to deal w/ Apple...
I don't see what Apple has to do with it. > okay thanks. > > here's where I am. > > I've downloaded matplotlib, numpy, python 2.7.3, xcode and macports to > simply plot this oh-so-simple code! > Which is: > > Curve fitting with python and pylab > #import the lib > from pylab import * > # assuming this data set > t = (0,5,10,15,20,25,30,35,40,50) > V = (1,7,14,15,16,22,25,27,28,30) > #show the data > plot(t, v, linewidth=2.0) > #assume an order > N = ? > #find the coefficient of the polynomial > coeffs = polyfit(t,v,N) > #get the polynomial output for the input > best = polyval(coeffs, t) > #print the coefficients > print(coeffs) > > I have written it like this in python 2.6: > > import os,sys > import numpy > #import pylab > > t = (0,5,10,15,20,25,30,35,40,50) > V = (1,7,14,15,16,22,25,27,28,30) > #scipy.plot(t,v,linewidth=2.0) > > n = 4 > coeffs = numpy.polyfit(t,V,n) > > best = numpy.polyval(coeffs,t) > > print coeffs > print best > > and when I run the program, I get this: > [ -1.68165168e-05 1.71262071e-03 -6.39152514e-02 1.59163337e+00 > 1.04578755e+00] > [ 1.04578755 7.60964036 12.11505162 15.46811522 18.32267732 > 21.08033633 23.89044289 26.6500999 29.0041625 29.81368631] > > when I run in 2.7.3 it looks like this: > import os,sys > import numpy as np > import pylab > > t = (0,5,10,15,20,25,30,35,40,50) > V = (1,7,14,15,16,22,25,27,28,30) > #scipy.plot(t,v,linewidth=2.0) > > n = 4 > coeffs = numpy.polyfit(t,V,n) > > best = numpy.polyval(coeffs,t) > > print coeffs > print best > > > And my error msg is this: > ImportError: No module named numpy > > any ideas? The problem in python 2.7 starts with the fact that numpy is evidently not installed for 2.7. Each version of python has its own set of libraries, so installing numpy for 2.6 does nothing for 2.7, and vice-versa. > What I'm looking for is a visual. With python 2.6, you may be almost there. Try running this in python 2.6: import numpy as np import matplotlib.pyplot as plt t = (0,5,10,15,20,25,30,35,40,50) V = (1,7,14,15,16,22,25,27,28,30) plt.plot(t, V, linewidth=2.0) n = 4 coeffs = np.polyfit(t,V,n) best = np.polyval(coeffs,t) print coeffs print best plt.show() Eric ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users