# # Splines cubiques # Vincent Legat - 2018 # Ecole Polytechnique de Louvain # import matplotlib from matplotlib import pyplot as plt matplotlib.rcParams['toolbar'] = 'None' plt.rcParams['figure.facecolor'] = 'silver' from numpy import * from scipy.interpolate import CubicSpline as spline X = arange(-55,70,10) U = [3.25, 3.37, 3.35, 3.20, 3.12, 3.02, 3.02, 3.07, 3.17, 3.32, 3.30, 3.20, 3.10] x = linspace(X[0],X[-1],100) uhLag = polyval(polyfit(X,U,len(X)-1),x) uhSpl = spline(X,U) plt.plot(x,uhLag,'--r',x,uhSpl(x),'-b') plt.plot(X,U,'or') plt.xlim([-60,80]) plt.ylim([3.0,3.5]) plt.show()