3D Scatter Plots in Dash syntax

Is there an example of the proper syntax for a 3D scatter plot (or 3D plotting in general) in Dash?

I have tried a few variations of plotly python syntax from the general plotly library as well as adding the “3D Scatter” and a “z” variable to a 2D scatter plot in Dash. Both did not work.

If someone has information as well on syntax for well functioning 3D surface plots I would be very grateful!

Some example syntax you could place in a Div or as a callback:

def scatter3D(value):
1 Like

Thank you! I was able to generate the graph fine, however, using Dash I am having trouble manipulating the axises. I would lie titles on the x, y, and z axis as well as different axis type as in either linear or log. I have a function set up to use radio items and drop downs to change these features, however, for 3D they do not change.

I have had success in 2D with the same goals.

So under layout, you want to add the scene dictionary:

        'scene': {'xaxis': {
                            'title': 'some xaxis',
                            'type': 'linear',

This gallery example has most of what you need: https://github.com/plotly/dash-drug-discovery-demo/blob/master/app.py

Thank you again! It worked perfectly for me.

Hi Adam!

Could you please show an example of how you integrated the function scatter3D in the code of your app?

Thanks in advance!

Hi! Sorry for the delayed reply. What types of code examples would you like? I can paste in my example of the plot in the ‘html’ but also the logic portion of how I generate the plot.

This is my return statement for the plot. I have posted it before so it may be what you are looking for as well:

return {

‘data’: traces,
‘layout’: go.Layout(
scene = {
‘xaxis’: {
‘title’: 'X: ’ + xaxis_column_name_3d,
‘type’: ‘linear’ if xaxis_type_3d == ‘Linear’ else ‘log’,
‘yaxis’: {
‘title’: 'Y: ’ + yaxis_column_name_3d,
‘type’: ‘linear’ if yaxis_type_3d == ‘Linear’ else ‘log’,
‘zaxis’: {
‘title’: 'Z: ’ + zaxis_column_name_3d,
‘type’: ‘linear’ if zaxis_type_3d == ‘Linear’ else ‘log’,
margin={‘l’: 40, ‘b’: 40, ‘t’: 10, ‘r’: 10},
legend={‘x’: 1, ‘y’: 1},
hovermode= ‘closest’