Smooth surface Plot with Pyplot
From the link you suggested, the example here is probably closest to what you want. You can use the example with your values,
import numpy as npfrom scipy import interpolateimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import axes3d, Axes3DX, 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()
Also, antialiased=True
may make it look better but I think is on by default. The first plot looks like this,
and the smoothed plot like this,
The problem with your the low frequency noise in your data is that it will be difficult to define a grid fine enough to resolve. You can adjust the level of smoothing with the s
argument to interpolate.bisplrep
or perhaps coarse grain/filter your data to leave only major trends (e.g. using scipy.ndimage.interpolation.zoom
if you have regular gridded data). Alternatively, consider a different type of plot such as pcolormesh as the data is essentially 2D.