Hello everyone, I’m trying to create a 3d interactive graph linked with three sliders. But when I run this code, I get blank 2d graph with sliders. If anyone can help me to find mistake in my code, it would be very helpful. Thank you
|A |C |B|
|191|11870402.57|150927.156|
|194|11534176.96|150926.613|
|200|8791715.569|150309.893|
|219|9058784.693|130344.409|
|193|11710374.76|150993.204|
|230|8966576.793|121803.204|
|196|11563137.82|147352.525|
|197|11559778.19|147360.662|
|232|8145250.015|134850.363|
|230|8960357.94|122119.87|
|241|8343604.908|118177.929|
from dash import Dash, dcc, html, Input, Output
import plotly.express as px
import pandas as pd
app = Dash(__name__)
app.layout = html.Div([
html.H4('Illustrations of the trade-offs between the key objectives'),
dcc.Graph(id="graph_scatter"),
html.P("A:"),
dcc.Slider(
id='3d-scatter-plot-x-range-slider',
min=df['A'].min(), max=df['A'].max(),
value=df['A'].max()),
html.P("B:"),
dcc.Slider(
id='3d-scatter-plot-y-range-slider',
min=df['B'].min(), max=df['B'].max(),
value=df['B'].max()),
html.P("C:"),
dcc.Slider(
id='3d-scatter-plot-z-range-slider',
min=df['C'].min(), max=df['C'].max(),
value=df['C'].max())
])
@app.callback(
Output('graph', 'figure'),
[Input('3d-scatter-plot-x-range-slider', 'value'),
Input('3d-scatter-plot-y-range-slider', 'value'),
Input('3d-scatter-plot-z-range-slider', 'value')
])
def update_bar_chart(slider_range_x, slider_range_y, slider_range_z):
df = pd.read_csv('ABC.csv') # replace with your own data source
low_x, high_x = slider_range_x
low_y, high_y = slider_range_y
low_z, high_z = slider_range_z
mask = (df.A > low_x) & (df.A < high_x) & (df.B > low_y) & (df.B < high_y) & (df.C > low_z) & (df.C < high_z)
fig = px.scatter_3d(mask,
x ='A', z='C',y='B')
return fig
if __name__ == "__main__":
app.run_server(debug=False)