What is the best method to do a second-order spline interpolation in Python? I already used interp1d
, but it's not quite what I want.
Example of what is intended.
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
x = [5,6,7,8,9,10,11]
y = [2,9,6,3,4,20,6]
xx = [1,2,3,4,5,6,7,8,9,10,11,12]
f = interp1d(x, y, kind='quadratic')
g = f(xx)
I want to calculate yy
, but I get the following error:
ValueError: A value in x_new is below the interpolation range.
I would like to get to python something like the following in matlab
x=[5,6,7,8,9,10,11]
y=[2,9,6,3,4,20,6]
xx=[1,2,3,4,5,6,7,8,9,10,11,12]
yy = spline(x,y,xx);
plot(x,y,'o',xx,yy)