Python Forum
How to create Custom Buttons for 3D Scatter plots in Plotly? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to create Custom Buttons for 3D Scatter plots in Plotly? (/thread-27292.html)



How to create Custom Buttons for 3D Scatter plots in Plotly? - yourboyjoe - Jun-01-2020

I am using plotly in Jupyter Notebook with Python to generate multiple 3D plots. All the data exists as points and thus is plotted with Scatter3d. Some of the data are circles, some are planes. See the overall model here:

[Image: 6Yxb3.png]

I am trying to create custom buttons to toggle the plane layers on and off within the plot itself. Like this example here:

[Image: bZWRM.png]

The buttons to the right turn the Cluster circles on and off. I would like the same to happen but for these layers, shown in the examples here:

[Image: LKOm1.png]

[Image: XtCZJ.png]

Currently, I am just commenting out that section of code and rerunning the script. My code that plots the circles and then the planes is below:

Code:

i=0
trace=go.Scatter3d(x=Data['X'][i],y=Data['Y'][i],z=Data['Z'][i])
layout=go.Layout(margin={'l': 0, 'r': 0, 'b': 0, 't': 0})
plot_figure = go.Figure(data=trace, layout=layout)
i=1
while i < len(Data):
    plot_figure.add_trace(go.Scatter3d(x=Data['X'][i],y=Data['Y'][i],z=Data['Z'][i],
             error_z=dict(type='constant',
                 value=Data['Error Top'][i],
                 valueminus=-Data['Error Bottom'][i],
                 thickness=0),
             surfaceaxis=1,
             surfacecolor=Data['Colors'][i],
             mode='lines',
             line=dict(color=Data['Colors'][i])))
    i=i+1    

plot_figure.add_trace(go.Scatter3d(x=Layer1['X'],y=Layer1['Y'],z=Layer1['Z'],
             mode='markers',
             opacity=0.4,name='Layer1',
             marker=dict(color='rgba(135, 10, 250, 0.5)',
                size=3,
                line=dict(color='MediumPurple',width=0))))

plot_figure.add_trace(go.Scatter3d(x=Layer2['X'],y=Layer2['Y'],z=Layer2['Z'],
             mode='markers',
             opacity=0.4,name='Layer2',
             marker=dict(color='rgba(135, 10, 250, 0.5)',
                size=3,
                line=dict(color='MediumPurple',width=0))))
Any help would be appreciated, thank you!