I devised the following code to mix the features of a surface plot and mesh -
x=np.linspace(-np.pi,np.pi,50)
u,v = np.meshgrid(x,x)
data = []
line_marker = dict(color='#000000', width=2)
for index in range(3):
w = np.sin((u**2+v**2)/(index+1))
for i, j, k in zip(u,v,w):
data.append(go.Scatter3d(x=i, y=j, z=k, mode='lines', line=line_marker,name="trace{}".format(index)))
for i, j, k in zip(u.T,v.T,w.T):
data.append(go.Scatter3d(x=i, y=j, z=k, mode='lines', line=line_marker,name="trace{}".format(index)))
data.append(go.Surface(x=u,
y=v,
z=w,name="trace{}".format(index)))
fig = go.Figure(data=data)
iplot(fig)
The plot is online at this link. How can I add the following features? -
- The 3D mesh+surfaces need to be assigned to a group that can be toggled on or off.
- I want the color of the surface to be fixed, independent of z-value. This is because the mesh gives me enough visual information about the surface. I would also want to assign the solid surface colors to the toggle buttons. Also get rids of the colorbar.
- Get rid of the numerous trace legends populating the right hand side of the figure.
EDIT 1:
Added groups and showlegend optons to the code, but it got rid of the legends completely. Still do not know how to restrict the colorscale to a single color.
x=np.linspace(-np.pi,np.pi,50)
u,v = np.meshgrid(x,x)
data = []
line_marker = dict(color='#000000', width=2)
for index in range(3):
w = np.sin((u**2+v**2)/(index+1))
groupname="group{}".format(index)
for i, j, k in zip(u,v,w):
data.append(go.Scatter3d(x=i, y=j, z=k, mode='lines',
line=line_marker,
showlegend=False,
legendgroup=groupname))
for i, j, k in zip(u.T,v.T,w.T):
data.append(go.Scatter3d(x=i, y=j, z=k, mode='lines',
line=line_marker,
showlegend=False,
legendgroup=groupname))
data.append(go.Surface(x=u,y=v,z=w,
name="trace{}".format(index),
showlegend=True,
legendgroup=groupname))
layout = go.Layout(
legend=dict(x=0,y=1,traceorder='normal',)
)
fig = go.Figure(data=data,layout=layout)
iplot(fig)