从您建议的链接来看,示例here可能最接近您想要的内容。你可以用这个例子来说明你的价值观import numpy as np
from scipy import interpolate
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d, Axes3D
X, Y = np.mgrid[-1:1:20j, -1:1:20j]
Z = (X+Y) * np.exp(-6.0*(X*X+Y*Y)) + np.random.rand(X.shape[0])
xnew, ynew = np.mgrid[-1:1:80j, -1:1:80j]
tck = interpolate.bisplrep(X, Y, Z, s=0)
znew = interpolate.bisplev(xnew[:,0], ynew[0,:], tck)
fig = plt.figure(figsize=(12,12))
ax = fig.gca(projection='3d')
ax.plot_surface(X, Y, Z, cmap='summer', rstride=1, cstride=1, alpha=None)
plt.show()
fig = plt.figure(figsize=(12,12))
ax = fig.gca(projection='3d')
ax.plot_surface(xnew, ynew, znew, cmap='summer', rstride=1, cstride=1, alpha=None, antialiased=True)
plt.show()
另外,antialiased=True可能会使它看起来更好,但我认为默认情况下是打开的。第一个情节是这样的
像这样平滑的情节
数据中低频噪声的问题是,很难定义足够精细的网格来解决。您可以使用s参数将平滑级别调整为interpolate.bisplrep,也可以使用粗粒度/过滤数据以只保留主要趋势(例如,如果有常规网格数据,则使用^{})。或者,考虑不同类型的绘图,例如pcolormesh,因为数据本质上是二维的