In [1]:
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d

In [2]:
x = np.linspace(0,10,10)
x


Out[2]:
array([  0.        ,   1.11111111,   2.22222222,   3.33333333,
         4.44444444,   5.55555556,   6.66666667,   7.77777778,
         8.88888889,  10.        ])

In [3]:
y = np.cos(x**2)
y


Out[3]:
array([ 1.        ,  0.32992906,  0.22396665,  0.11527995,  0.61884057,
        0.85161952,  0.89509715, -0.69414366, -0.89041993,  0.86231887])

In [4]:
plt.plot(x,y,'o')


Out[4]:
[<matplotlib.lines.Line2D at 0x7ff13802a790>]

In [21]:
f = interp1d(x, y, kind='cubic')
x_values = np.linspace(0, 10, 40)
plot(x_values,f(x_values),'-')


Out[21]:
[<matplotlib.lines.Line2D at 0x7ff133b83350>]

In [22]:
plt.plot(x,y,'o',x_values,f(x_values),'-') 
plt.legend(['data points', 'cubic'], loc='best')
plt.show()



In [ ]: