From: <fer...@us...> - 2007-07-31 06:53:09
|
Revision: 3643 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3643&view=rev Author: fer_perez Date: 2007-07-30 23:53:07 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Put in changes that for some reason SVN was not seeing in my local copy. Problem reported by Stefan Modified Paths: -------------- trunk/py4science/examples/spline_demo.py Modified: trunk/py4science/examples/spline_demo.py =================================================================== --- trunk/py4science/examples/spline_demo.py 2007-07-30 23:22:48 UTC (rev 3642) +++ trunk/py4science/examples/spline_demo.py 2007-07-31 06:53:07 UTC (rev 3643) @@ -10,13 +10,19 @@ tfine = N.arange(0.0, 5, 0.01) tcoarse = N.arange(0.0, 5, 0.1) -s = N.cos(N.pi*tcoarse) * N.sin(2*N.pi*tcoarse) +def func(t): + return N.cos(N.pi*t) * N.sin(2*N.pi*t) # create sinterp by computing the spline fitting tcoarse to s and then -evaluating it on tfine. Plot tcoarse vs s with markers and tfine vs -sinterp with a solid line +# evaluating it on tfine. Plot tcoarse vs s with markers and tfine vs +# sinterp with a solid line +s = func(tcoarse) + tck = interpolate.splrep(tcoarse, s, s=0) sinterp = interpolate.splev(tfine, tck, der=0) -P.plot(tcoarse, s, 'o', tfine, sinterp) +P.plot(tcoarse, s, 'o', label='coarse') +P.plot(tfine, sinterp, '+', label='fit') +P.plot(tfine, func(tfine), '-', label='actual') +P.legend() P.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |