✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

How to create Custom Buttons for 3D Scatter plots in Plotly (Python)?

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:

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

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:

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! Thanks in advance.