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]:
In [3]:
y = np.cos(x**2)
y
Out[3]:
In [4]:
plt.plot(x,y,'o')
Out[4]:
In [21]:
f = interp1d(x, y, kind='cubic')
x_values = np.linspace(0, 10, 40)
plot(x_values,f(x_values),'-')
Out[21]:
In [22]:
plt.plot(x,y,'o',x_values,f(x_values),'-')
plt.legend(['data points', 'cubic'], loc='best')
plt.show()
In [ ]: