Python Forum
How to create Custom Buttons for 3D Scatter plots in Plotly?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create Custom Buttons for 3D Scatter plots in Plotly?
#1
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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I want to create custom charts in Python. js1152410 1 523 Nov-13-2023, 05:45 PM
Last Post: gulshan212
  Multiple Plots in Spyder PythonAndMe2023 0 862 Feb-03-2023, 07:00 PM
Last Post: PythonAndMe2023
Shocked plt.scatter() errors asja2010 0 1,463 Oct-13-2022, 08:15 AM
Last Post: asja2010
  binning_endpoints ->plotly Luis_liverpool 0 829 Aug-09-2022, 10:13 AM
Last Post: Luis_liverpool
  Subplot - Plotting 4 plots on the same row Menthix 1 1,415 Nov-07-2021, 09:03 PM
Last Post: deanhystad
  How to invert scatter plot axis Mark17 3 2,492 Sep-22-2021, 04:45 PM
Last Post: jefsummers
  plotly expression problem Visiting 2 1,987 May-16-2021, 12:28 AM
Last Post: Visiting
  Animated scatter plot maximan 0 1,632 Jan-18-2021, 03:53 PM
Last Post: maximan
  create loop of subplot plotly dash without hardcode tonycat 0 3,900 Sep-23-2020, 08:40 AM
Last Post: tonycat
  Sharing X Axis in Sub plots JoeDainton123 1 2,166 Aug-22-2020, 04:11 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020