Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Sure, there are a couple of ways. Here are two:

import numpy
from scipy import interpolate

data = [(x, sin(x)**2+(x % 2.7)**3) for x in numpy.linspace(0, 5, 20)]

# separate data into x and y components
xx,yy = zip(*data)

# build spline in two ways..
scipy_spline = interpolate.InterpolatedUnivariateSpline(xx, yy)

gsl_spline = spline(data)

p = list_plot(data, color="green")
p += plot(scipy_spline, (0, 5), color="red")
p += plot(gsl_spline, (0, 5), linestyle='--', color="blue")

Note that if you build the spaces yourself and use the built-in spline object you wouldn't need to import anything.

image description