@app.callback(
Output("scat", "figure"),
[Input("select-xaxis", "value"),
Input("select-yaxis", "value"),
Input("select-zaxis", "value"),
Input("select-species", "value"),
Input('studies', 'value'),
Input('foams', 'value'),
Input('surfactants', 'value'),
Input('additives', 'value'),
Input('lp', 'value')],
)
def update_scat(selected_x, selected_y, selected_z, selected_species, st, fo, sur, add, lp):
c = dv[dv['Study'].isin(st)]
le = c[c['Foam'].isin(fo)]
an = le[le['Surfactant'].isin(sur)]
ed = an[an['Additive'].isin(add)]
cleaned = ed[ed['LiquidPhase'].isin(lp)]
fig = [go.Figure(data=go.Scatter(x=cleaned[selected_x].to_numpy(),
y=cleaned[selected_y].to_numpy(),
mode = 'markers',
marker = {
"size":20,
"color":cleaned[selected_species],
},
text="Study: " + cleaned.Study + "<br />Foam: " + cleaned.Foam + "<br />Surfactant: " + cleaned.Surfactant + "<br />Additive: " + cleaned.Additive + "<br />Liquid Phase: " + cleaned.LiquidPhase,))]
return {"data": fig,
"layout": go.Layout(
paper_bgcolor="#202020",
height=938,
xaxis={"title": f"{selected_x.title()}"},
yaxis={"title": f"{selected_y.title()}"}, )
}
Above is my code. I am creating a 2-d scatter plot from within a tab, when I use fig.show() in my return statement it works (but gives me an error of course). With the above code, I get an empty plot. I have tried changing around my x and y axes, but to no avail. I have a 3d graph in another tab, so I know the data/variables used work. Please let me know if you see the problem.