## [Matplotlib-users] Fwd: How to plot Chebyshev polynolmials

 [Matplotlib-users] Fwd: How to plot Chebyshev polynolmials From: - 2012-01-10 15:22:20 ```I'm not used to reply-all ---------- Forwarded message ---------- From: Date: Tue, Jan 10, 2012 at 10:20 AM Subject: Re: [Matplotlib-users] How to plot Chebyshev polynolmials To: Fabien Lafont On Tue, Jan 10, 2012 at 9:46 AM, Fabien Lafont wrote: > No I just want to plot the third Shebitchev polynomial. the vander functions give you the basis functions for a given x, or use coefficients only for the polynomial you want, if I understand correctly what you want >>> import numpy as np >>> from numpy import polynomial as poly >>> chebs = [poly.Chebyshev(coef) for coef in np.eye(5)] >>> for p in chebs: plt.plot(x, p(x)) ... [] [] [] [] [] >>> plt.show() or >>> plt.plot(poly.chebvander(x, 5)) Josef > > 2012/1/10 Daniel Hyams : >> I think that you're misusing Chebyshev (do you really only want to give "3" >> as a coefficient..which is just the constant function 3), and you have to >> evaluate it in order to give matplotlib some x and y data to plot. >> >> from matplotlib import pyplot as plt >> import numpy as np >> >> x = np.linspace(-1.0,1.0) >> test = np.polynomial.Chebyshev((1,2,3)) >> y = test(x) >> plt.plot(x,y) >> plt.show() >> >> >> >> On Tue, Jan 10, 2012 at 9:10 AM, Fabien Lafont >> wrote: >>> >>> I'm trying to plot Chebyshev polynolmials using: >>> numpy.polynomial.Chebyshev: >>> >>> >>> import math >>> from numpy import * >>> from numpy import polynomial as pol >>> from pylab import * >>> from scipy import * >>> from scipy import optimize >>> import warnings >>> warnings.simplefilter('ignore', np.RankWarning) >>> >>> >>> test = pol.Chebyshev(3) >>> print test >>> plot (test) >>> >>> >>> show() >>> ======================================================================= >>> >>> The print return:      cheb([ 3.]) >>> >>> ======================================================================= >>> and plot : >>> >>> >>> Traceback (most recent call last): >>>  File "T:\Dropbox\Thèse\Python\fit sonde\test_poly_Tcheb.py", line >>> 32, in >>>    plot (test) >>>  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 2458, in >>> plot >>>    ret = ax.plot(*args, **kwargs) >>>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 3849, in >>> plot >>>    self.add_line(line) >>>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1443, >>> in add_line >>>    self._update_line_limits(line) >>>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1451, >>> in _update_line_limits >>>    p = line.get_path() >>>  File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 644, >>> in get_path >>>    self.recache() >>>  File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 401, in >>> recache >>>    y = np.asarray(yconv, np.float_) >>>  File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line >>> 235, in asarray >>>    return array(a, dtype, copy=False, order=order) >>> TypeError: float() argument must be a string or a number >>> >>> >>> ------------------------------------------------------------------------------ >>> Write once. Port to many. >>> Get the SDK and tools to simplify cross-platform app development. Create >>> new or port existing apps to sell to consumers worldwide. Explore the >>> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join >>> http://p.sf.net/sfu/intel-appdev >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users@... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> >> >> -- >> Daniel Hyams >> dhyams@... >> >> ------------------------------------------------------------------------------ >> Write once. Port to many. >> Get the SDK and tools to simplify cross-platform app development. Create >> new or port existing apps to sell to consumers worldwide. Explore the >> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join >> http://p.sf.net/sfu/intel-appdev >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users@... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ```

 [Matplotlib-users] How to plot Chebyshev polynolmials From: Fabien Lafont - 2012-01-10 14:10:35 ```I'm trying to plot Chebyshev polynolmials using: numpy.polynomial.Chebyshev: import math from numpy import * from numpy import polynomial as pol from pylab import * from scipy import * from scipy import optimize import warnings warnings.simplefilter('ignore', np.RankWarning) test = pol.Chebyshev(3) print test plot (test) show() ======================================================================= The print return: cheb([ 3.]) ======================================================================= and plot : Traceback (most recent call last): File "T:\Dropbox\Thèse\Python\fit sonde\test_poly_Tcheb.py", line 32, in plot (test) File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 2458, in plot ret = ax.plot(*args, **kwargs) File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 3849, in plot self.add_line(line) File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1443, in add_line self._update_line_limits(line) File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1451, in _update_line_limits p = line.get_path() File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 644, in get_path self.recache() File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 401, in recache y = np.asarray(yconv, np.float_) File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line 235, in asarray return array(a, dtype, copy=False, order=order) TypeError: float() argument must be a string or a number ```
 Re: [Matplotlib-users] How to plot Chebyshev polynolmials From: Daniel Hyams - 2012-01-10 14:34:31 Attachments: Message as HTML ```I think that you're misusing Chebyshev (do you really only want to give "3" as a coefficient..which is just the constant function 3), and you have to evaluate it in order to give matplotlib some x and y data to plot. from matplotlib import pyplot as plt import numpy as np x = np.linspace(-1.0,1.0) test = np.polynomial.Chebyshev((1,2,3)) y = test(x) plt.plot(x,y) plt.show() On Tue, Jan 10, 2012 at 9:10 AM, Fabien Lafont wrote: > I'm trying to plot Chebyshev polynolmials using: > numpy.polynomial.Chebyshev: > > > import math > from numpy import * > from numpy import polynomial as pol > from pylab import * > from scipy import * > from scipy import optimize > import warnings > warnings.simplefilter('ignore', np.RankWarning) > > > test = pol.Chebyshev(3) > print test > plot (test) > > > show() > ======================================================================= > > The print return: cheb([ 3.]) > > ======================================================================= > and plot : > > > Traceback (most recent call last): > File "T:\Dropbox\Thèse\Python\fit sonde\test_poly_Tcheb.py", line > 32, in > plot (test) > File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 2458, in > plot > ret = ax.plot(*args, **kwargs) > File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 3849, in > plot > self.add_line(line) > File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1443, > in add_line > self._update_line_limits(line) > File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1451, > in _update_line_limits > p = line.get_path() > File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 644, > in get_path > self.recache() > File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 401, in > recache > y = np.asarray(yconv, np.float_) > File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line > 235, in asarray > return array(a, dtype, copy=False, order=order) > TypeError: float() argument must be a string or a number > > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Daniel Hyams dhyams@... ```
 Re: [Matplotlib-users] How to plot Chebyshev polynolmials From: Fabien Lafont - 2012-01-10 14:47:02 ```No I just want to plot the third Shebitchev polynomial. 2012/1/10 Daniel Hyams : > I think that you're misusing Chebyshev (do you really only want to give "3" > as a coefficient..which is just the constant function 3), and you have to > evaluate it in order to give matplotlib some x and y data to plot. > > from matplotlib import pyplot as plt > import numpy as np > > x = np.linspace(-1.0,1.0) > test = np.polynomial.Chebyshev((1,2,3)) > y = test(x) > plt.plot(x,y) > plt.show() > > > > On Tue, Jan 10, 2012 at 9:10 AM, Fabien Lafont > wrote: >> >> I'm trying to plot Chebyshev polynolmials using: >> numpy.polynomial.Chebyshev: >> >> >> import math >> from numpy import * >> from numpy import polynomial as pol >> from pylab import * >> from scipy import * >> from scipy import optimize >> import warnings >> warnings.simplefilter('ignore', np.RankWarning) >> >> >> test = pol.Chebyshev(3) >> print test >> plot (test) >> >> >> show() >> ======================================================================= >> >> The print return:      cheb([ 3.]) >> >> ======================================================================= >> and plot : >> >> >> Traceback (most recent call last): >>  File "T:\Dropbox\Thèse\Python\fit sonde\test_poly_Tcheb.py", line >> 32, in >>    plot (test) >>  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 2458, in >> plot >>    ret = ax.plot(*args, **kwargs) >>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 3849, in >> plot >>    self.add_line(line) >>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1443, >> in add_line >>    self._update_line_limits(line) >>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1451, >> in _update_line_limits >>    p = line.get_path() >>  File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 644, >> in get_path >>    self.recache() >>  File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 401, in >> recache >>    y = np.asarray(yconv, np.float_) >>  File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line >> 235, in asarray >>    return array(a, dtype, copy=False, order=order) >> TypeError: float() argument must be a string or a number >> >> >> ------------------------------------------------------------------------------ >> Write once. Port to many. >> Get the SDK and tools to simplify cross-platform app development. Create >> new or port existing apps to sell to consumers worldwide. Explore the >> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join >> http://p.sf.net/sfu/intel-appdev >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users@... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > -- > Daniel Hyams > dhyams@... > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ```
 Re: [Matplotlib-users] How to plot Chebyshev polynolmials From: Daniel Hyams - 2012-01-10 15:41:56 Attachments: Message as HTML ```Regardless of exactly which polynomial you are after, I've showed you how to plot a cheb. poly. Can you not work with the code given and plot the exact variation of polynomial you want? On Tue, Jan 10, 2012 at 9:46 AM, Fabien Lafont wrote: > No I just want to plot the third Shebitchev polynomial. > > 2012/1/10 Daniel Hyams : > > I think that you're misusing Chebyshev (do you really only want to give > "3" > > as a coefficient..which is just the constant function 3), and you have to > > evaluate it in order to give matplotlib some x and y data to plot. > > > > from matplotlib import pyplot as plt > > import numpy as np > > > > x = np.linspace(-1.0,1.0) > > test = np.polynomial.Chebyshev((1,2,3)) > > y = test(x) > > plt.plot(x,y) > > plt.show() > > > > > > > > On Tue, Jan 10, 2012 at 9:10 AM, Fabien Lafont > > wrote: > >> > >> I'm trying to plot Chebyshev polynolmials using: > >> numpy.polynomial.Chebyshev: > >> > >> > >> import math > >> from numpy import * > >> from numpy import polynomial as pol > >> from pylab import * > >> from scipy import * > >> from scipy import optimize > >> import warnings > >> warnings.simplefilter('ignore', np.RankWarning) > >> > >> > >> test = pol.Chebyshev(3) > >> print test > >> plot (test) > >> > >> > >> show() > >> ======================================================================= > >> > >> The print return: cheb([ 3.]) > >> > >> ======================================================================= > >> and plot : > >> > >> > >> Traceback (most recent call last): > >> File "T:\Dropbox\Thèse\Python\fit sonde\test_poly_Tcheb.py", line > >> 32, in > >> plot (test) > >> File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 2458, > in > >> plot > >> ret = ax.plot(*args, **kwargs) > >> File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 3849, in > >> plot > >> self.add_line(line) > >> File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1443, > >> in add_line > >> self._update_line_limits(line) > >> File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1451, > >> in _update_line_limits > >> p = line.get_path() > >> File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 644, > >> in get_path > >> self.recache() > >> File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 401, in > >> recache > >> y = np.asarray(yconv, np.float_) > >> File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line > >> 235, in asarray > >> return array(a, dtype, copy=False, order=order) > >> TypeError: float() argument must be a string or a number > >> > >> > >> > ------------------------------------------------------------------------------ > >> Write once. Port to many. > >> Get the SDK and tools to simplify cross-platform app development. Create > >> new or port existing apps to sell to consumers worldwide. Explore the > >> Intel AppUpSM program developer opportunity. > appdeveloper.intel.com/join > >> http://p.sf.net/sfu/intel-appdev > >> _______________________________________________ > >> Matplotlib-users mailing list > >> Matplotlib-users@... > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > > > -- > > Daniel Hyams > > dhyams@... > > > > > ------------------------------------------------------------------------------ > > Write once. Port to many. > > Get the SDK and tools to simplify cross-platform app development. Create > > new or port existing apps to sell to consumers worldwide. Explore the > > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > > http://p.sf.net/sfu/intel-appdev > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users@... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > -- Daniel Hyams dhyams@... ```
 [Matplotlib-users] Fwd: How to plot Chebyshev polynolmials From: - 2012-01-10 15:22:20 ```I'm not used to reply-all ---------- Forwarded message ---------- From: Date: Tue, Jan 10, 2012 at 10:20 AM Subject: Re: [Matplotlib-users] How to plot Chebyshev polynolmials To: Fabien Lafont On Tue, Jan 10, 2012 at 9:46 AM, Fabien Lafont wrote: > No I just want to plot the third Shebitchev polynomial. the vander functions give you the basis functions for a given x, or use coefficients only for the polynomial you want, if I understand correctly what you want >>> import numpy as np >>> from numpy import polynomial as poly >>> chebs = [poly.Chebyshev(coef) for coef in np.eye(5)] >>> for p in chebs: plt.plot(x, p(x)) ... [] [] [] [] [] >>> plt.show() or >>> plt.plot(poly.chebvander(x, 5)) Josef > > 2012/1/10 Daniel Hyams : >> I think that you're misusing Chebyshev (do you really only want to give "3" >> as a coefficient..which is just the constant function 3), and you have to >> evaluate it in order to give matplotlib some x and y data to plot. >> >> from matplotlib import pyplot as plt >> import numpy as np >> >> x = np.linspace(-1.0,1.0) >> test = np.polynomial.Chebyshev((1,2,3)) >> y = test(x) >> plt.plot(x,y) >> plt.show() >> >> >> >> On Tue, Jan 10, 2012 at 9:10 AM, Fabien Lafont >> wrote: >>> >>> I'm trying to plot Chebyshev polynolmials using: >>> numpy.polynomial.Chebyshev: >>> >>> >>> import math >>> from numpy import * >>> from numpy import polynomial as pol >>> from pylab import * >>> from scipy import * >>> from scipy import optimize >>> import warnings >>> warnings.simplefilter('ignore', np.RankWarning) >>> >>> >>> test = pol.Chebyshev(3) >>> print test >>> plot (test) >>> >>> >>> show() >>> ======================================================================= >>> >>> The print return:      cheb([ 3.]) >>> >>> ======================================================================= >>> and plot : >>> >>> >>> Traceback (most recent call last): >>>  File "T:\Dropbox\Thèse\Python\fit sonde\test_poly_Tcheb.py", line >>> 32, in >>>    plot (test) >>>  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 2458, in >>> plot >>>    ret = ax.plot(*args, **kwargs) >>>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 3849, in >>> plot >>>    self.add_line(line) >>>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1443, >>> in add_line >>>    self._update_line_limits(line) >>>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1451, >>> in _update_line_limits >>>    p = line.get_path() >>>  File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 644, >>> in get_path >>>    self.recache() >>>  File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 401, in >>> recache >>>    y = np.asarray(yconv, np.float_) >>>  File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line >>> 235, in asarray >>>    return array(a, dtype, copy=False, order=order) >>> TypeError: float() argument must be a string or a number >>> >>> >>> ------------------------------------------------------------------------------ >>> Write once. Port to many. >>> Get the SDK and tools to simplify cross-platform app development. Create >>> new or port existing apps to sell to consumers worldwide. Explore the >>> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join >>> http://p.sf.net/sfu/intel-appdev >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users@... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> >> >> -- >> Daniel Hyams >> dhyams@... >> >> ------------------------------------------------------------------------------ >> Write once. Port to many. >> Get the SDK and tools to simplify cross-platform app development. Create >> new or port existing apps to sell to consumers worldwide. Explore the >> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join >> http://p.sf.net/sfu/intel-appdev >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users@... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ```

No, thanks