0
np.linspace()
コマンドを使用して8つのデータポイントを補間したいと考えています。ここに私のコードがあります:1D 3次立方体と線形補間のパイソン
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
X = np.linspace(-2.5, 2.0, num=8, endpoint=True)
Y = np.linspace(1, 44, num=44, endpoint=True)
f = interp1d(X,Y)
f2 = interp1d(X, Y, kind='cubic')
Xnew = np.linspace(-2.5, 2.0, num=44, endpoint=True)
plt.plot(X, Y, 'o', Xnew, f(Xnew), Xnew, f2(Xnew), '--' )
plt.legend(['data', 'linear', 'cubic'], loc='best')
plt.show()