慕运维8079593
我认为您需要先对数据进行网格化。我根据您的数据创建了一个示例。import pandas as pdimport numpy as npimport plotly.graph_objects as go from scipy.interpolate import griddata#Read datadata = pd.read_csv('data.txt', header=0, delimiter='\t')#Create meshgrid for x,yxi = np.linspace(min(data['x']), max(data['x']), num=100)yi = np.linspace(min(data['y']), max(data['y']), num=100)x_grid, y_grid = np.meshgrid(xi,yi)#Grid dataz_grid = griddata((data['x'],data['y']),data['z'],(x_grid,y_grid),method='cubic')# Plotly 3D Surfacefig = go.Figure(go.Surface(x=x_grid,y=y_grid,z=z_grid, colorscale='viridis',showlegend=True))fig.show()来自示例数据的 3D 表面您可以使用不同的网格划分方法(三次、线性、最近) https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html