I am trying to plot a 3D scan of a leg using Plotly's Mesh3D
.
I have used scatter_3d
with the XYZ points to show this concept using:
fig = px.scatter_3d(df, x='x', y='y', z='z', opacity = 0.8)
However, it does not look like a surface. Therefore, I tried Mesh3d
, using:
fig = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z, color='lightpink', opacity=0.50)])
Obviously, this plot is not smooth. I've tried to sort the df before rendering the plots but it did not help.
To reiterate, I am looking for a smooth surface plot of this XYZ data.
Here is the scan's XYZ data.
Edit: Continued Information on Introduction of Surface Plot
I implemented the Surface plot with the code below. Unfortunately, no plot is rendered (no error is accompanied, either).
colnames = ['x', 'y', 'z']
df = pd.read_csv('sandbox\leg.txt', sep = ' ', header = None, names = colnames)
x, y = np.array(df['x'].tolist()), np.array(df['y'].tolist())
df2 = df.pivot(index = 'x', columns = 'y', values = 'z')
z = df2.values
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])
fig.show()