vl = widgets.Dropdown(
options=list(df["category"].unique()),
value=list(df["category"].unique())[0],
disabled=False,
description="Vl:",
)
trace1 = go.Histogram(x = df["c1"], y= df["c2"], histfunc = "sum", name="xyz")
trace2 = go.Histogram(x=df["c1"], name = "abc")
g = go.FigureWidget(data=[trace1, trace2],
layout=go.Layout(
title=dict(
text="distribution"
),
))
def validate():
if vl.value in df["category"].unique():
return True
else:
return False
def response(change):
if validate():
filter_list = [i for i in df["category"] == vl.value]
temp_df = df[filter_list]
x1 = temp_df["category"]
with g.batch_update():
g.data[0].x = x1
vl.observe(response, names="value")
container2 = widgets.HBox([vl])
widgets.VBox([container2,
g])
While clicking on dropdown the results shown are incorrect.What am I missing here?