I have two arrays, x
and y
. I want to create a natural cubic spline for the arrays.
I can't figure out how to exactly plot the graph for the spline.
import numpy as np
from scipy.interpolate import CubicSpline
# Calculate 5 natural cubic spline polynomials for 6 points.
# (x,y) = (0,12) (1,14) (2,22) (3,39) (4,58) (5,77)
x = np.array([0, 1, 2, 3, 4, 5 ])
y = np.array([12, 14, 22, 39, 58, 77])
# Calculate natural cubic spline polynomials.
cs = CubicSpline(x, y, bc_type='natural')