@Darius wrote:
Hi everybody,
I am new to plotly dash and trying to make a stacked bar chart based on a pandas df. it works for one df but when I try to make a function to have a plot for each location and link it to a Dropdown widget I get an error. please help me.def update_plot(locations): '''locations: list''' data = [] for idx in range(len(locations)): trace = ( go.Bar(name='{}'.format(i), x=invest_dfs[idx].index.get_level_values('SHORT_TECH')\ [invest_dfs[idx].index.get_level_values('YEAR') == i], y=invest_dfs[idx].VALUE.loc[invest_dfs[idx].index.get_level_values('YEAR') == i])\ for i in invest_dfs[idx].index.get_level_values('YEAR').unique() ) data.append(trace) fig = go.Figure(data=data) # Change the bar mode fig.update_layout(barmode='stack') py.offline.iplot(fig) LOCS = widgets.Dropdown(options=list(locations),value='Rotterdam', description='locations') widgets.interactive(update_plot)
the error is:
ValueError: cannot find widget or abbreviation for argument: 'locations'
I am running it on jupyter notebook
thanks
Posts: 1
Participants: 1