一个简单的搜索就会有所帮助。
你的问题基本上是
scipy.interpolate.interp2d documentation.
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy import interpolate
import numpy as np
xs = [ 0.15, 0.35, 0.5, 0.67, 0.8 ]
ys = [ 0.01, 0.05, 0.1, 0.2, 0.3 ]
zz = np.array( [
0.75, 0.83, 1.00, 0.92, 0.91,
0.75, 0.82, 0.87, 0.88, 0.88,
0.74, 0.81, 0.84, 0.83, 0.83,
0.72, 0.76, 0.77, 0.76, 0.76,
0.72, 0.72, 0.72, 0.72, 0.72
] ).reshape( ( 5, 5 ) )
xx, yy = np.meshgrid( xs, ys )
f = interpolate.interp2d( xx, yy, zz, kind='cubic' )
fig = plt.figure()
ax = fig.add_subplot( 1, 1, 1, projection='3d' )
ax.plot_surface( xx, yy, zz)
x2 = np.linspace( .15,.8,50 )
y2 = np.linspace( .01,.3,50 )
xx2, yy2 = np.meshgrid( x2, y2 )
zz2 = f( x2, y2 )
fig2 = plt.figure()
bx = fig2.add_subplot( 1, 1, 1, projection='3d' )
bx.plot_surface( xx2, yy2, zz2 )
plt.show()
提供原始数据
以及 50 x 50 网格上的三次插值