[SciPy-user] Plotting an array
elcorto at gmx.net
Tue Oct 10 11:15:21 CDT 2006
Andrew B. Young wrote:
> I believe this is a rookie question but the I've not discovered the
> answer so easily. The code below, copied from a posting I found,
> produces a graph with a straight line across zero. Plotting just t,
> plot(t), produces a line either zero or one. I am sure it has
> something to do with plotting an array versus plotting a python list.
Hmmm, t, y, tnew and ynew are <type 'numpy.ndarray'> in my case (try
type(t) etc. to find out).
The only list is tck, but is not plotted (it contains infos about the
spline and is passed to splev).
matplotlib 0.87.5 Rev 2761
> I would be happy for a pointer to the reference material for me to
> read. http://www.scipy.org/Documentation has not yet lead me to the
> t = arange(0, 2.0, 0.1)
> y = sin(2*pi*t)
> tck = interpolate.splrep(t, y, s=0)
> tnew = arange(0, 2.0, 0.01)
> ynew = interpolate.splev(tnew, tck, der=0)
> plot(t, y, 'o', tnew, ynew)
PS: Rather unimportant note to the scipy guys:
In : len(tck)
In : type(tck)
Out: <type 'list'>
The splrep docstring says tck is a len 3 tuple, not a list ...
Random number generation is the art of producing pure gibberish as
quickly as possible.
More information about the SciPy-user