I have a multindex graph and i want to give it legend based on the color i.e., ‘experiece_level’ array
work_year is level
fig = go.Figure()
fig.add_trace(go.Bar(x=s_by_year_exp.index.get_level_values('work_year'),y=s_by_year_exp['salary_in_usd'],text=s_by_year_exp.index.get_level_values('experience_level').map(exp_dict),marker=dict(color=['green','yellow','blue','red']*4),showlegend=True))
fig.update_layout(barmode="stack")
fig.show()
if i plot this i get this
i want the legend be like color box - experience level
I know one can run a loop but i want to know where it is possible to just make it in one line itself
Thankyou in Advance for Answer