0

换句话说,我得到了一组与值 b 相关联的数据点 (x,y,z),我想尽可能准确地插入这些数据。scipy.interpolate.griddata 只能做线性插值,其他选项是什么?

4

1 回答 1

0

分别插值 x、y、z 怎么样?我修改了本教程示例并为其添加了插值:

import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import InterpolatedUnivariateSpline

mpl.rcParams['legend.fontsize'] = 10

# let's take only 20 points for original data:
n = 20

fig = plt.figure()
ax = fig.gca(projection='3d')
theta = np.linspace(-4 * np.pi, 4 * np.pi, n)
z = np.linspace(-2, 2, n)
r = z**2 + 1
x = r * np.sin(theta)
y = r * np.cos(theta)
ax.plot(x, y, z, label='rough curve')

# this variable represents distance along the curve:
t = np.arange(n)

# now let's refine it to 100 points:
t2 = np.linspace(t.min(), t.max(), 100)

# interpolate vector components separately:
x2 = InterpolatedUnivariateSpline(t, x)(t2)
y2 = InterpolatedUnivariateSpline(t, y)(t2)
z2 = InterpolatedUnivariateSpline(t, z)(t2)

ax.plot(x2, y2, z2, label='interpolated curve')

ax.legend()
plt.show()

结果如下所示: 3d 线图

更新

第一次没看懂问题,不好意思。

您可能正在寻找三次插值。试试这个

于 2016-07-27T06:52:54.570 回答