Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
624 views
in Technique[技术] by (71.8m points)

python - How to plot edge lines on the 3D surface in plotly?

I have a 3D sufrace formed by some convexhull points. My code looks like:

  
hull = scipy.spatial.ConvexHull(coordinates) #coordinates are 3d array of needed coordinates

polyhedra_points = hull.vertices.tolist()
coordinates_all = result_fin[['Teta_N', 'Teta_V', 'Teta_chi']].to_numpy() #result_fin is dataframe with all coordinates
polyhedra_coordinates = coordinates_all[polyhedra_points]


fig = go.Figure(data=[go.Scatter3d(x=result_fin.Teta_N, y=result_fin.Teta_V, z=result_fin.Teta_chi, mode='markers', marker=dict(size = 5, color = 'blue'))])

   
fig.add_trace(go.Mesh3d(x=polyhedra_coordinates[:, 0], 
                        y=polyhedra_coordinates[:, 1], 
                        z=polyhedra_coordinates[:, 2],
                        text = polyhedra_df.composition, #we see the names of the polyhedra points
                        color="blue",
                        name='Laves',
                        contour = dict(color = 'blue', show = True, width = 10),
                        opacity=.3,
                        alphahull=0
                       ),
             )

fig

My plot now Surface without edge lines

But I need to have forming lines on it, like here (this one I made by 3D matplotlib, but it is not interactive enough):

Surface with edge lines made in matplotlib

Here it was done like this:

ax = plt.axes(projection='3d')
  
hull = scipy.spatial.ConvexHull(coordinates)
faces = hull.simplices
polyhedra_points = hull.vertices.tolist()

for i in faces:

    tri = Poly3DCollection(coordinates[i])
    tri.set_color('blue') 
    tri.set_alpha(0.3)
    ax.add_collection3d(tri)
    
ax.scatter(xs = result_fin.Teta_N, ys= result_fin.Teta_V, zs=result_fin.Teta_chi, color = 'blue', label='laves', s = 15)
    
ax.set_xlabel(r"$Theta_{N}$")
ax.set_ylabel(r"$Theta_{V}$")
ax.set_zlabel(r"$Theta_{chi}$")
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.05), ncol=4)

I want to make the same as I made in 2nd picture, but in plotly. How can I do this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...