Trying to create a histogram with a drop down button so you can switch between views. Want the drop down button to be a list of the column names. The following code gives a histogram with a button but the button only has one option which is the final column. How do I get it so the button is a drop down list of all the column names?
d = {'col1': [1, 2], 'col2': [3, 4]} df_date_all = pd.DataFrame(data=d)
fig_drop = go.FigureWidget() addAll = True
for column in df_date_all.columns.to_list():
try:
fig_drop.add_trace(
go.Histogram(
x = df_date_all[column],
name = column
)
)
fig_drop.update_layout(
updatemenus=[go.layout.Updatemenu(
active = 0,
buttons = list([
dict(label = column,
method = 'update',
args = [{'visible': df_date_all.columns.isin([column]),
'title': column,
'showlegend': False}])
])
)
])
fig_drop.update_layout(
title_text='Frequency by Date',
xaxis_title_text='Date',
yaxis_title_text='Query Count')
except:
pass
fig_drop.show()