Is it possible to make one legend control two subplots with traces with shared names?
This is my current code and results, and I want to get a legend without repeated names.
##rewards
i=0
for agent in df.agent_id.unique():
df_ag=df.loc[df['agent_id']==agent]
df_ag.sort_values(by=['round'])
fig.add_trace(go.Scatter(x=df_ag['round'], y=smoothTriangle(df_ag['performance'],smooth_degree),name='agent '+str(i)),1,1)
i=i+1
df2=pd.read_sql_query("select performance, round from sg_models",conn)
df2.sort_values(by=['round'])
fig.add_trace(go.Scatter(x=df2['round'], y=smoothTriangle(df2['performance'],smooth_degree),name='Global'),1,1)
##losses
i=0
for agent in df.agent_id.unique():
df_ag=df.loc[df['agent_id']==agent]
df_ag.sort_values(by=['round'])
fig.add_trace(go.Scatter(x=df_ag['round'], y=smoothTriangle(df_ag['performance'],smooth_degree),name='agent '+str(i)),1,2)
i=i+1
df2=pd.read_sql_query("select performance, round from sg_models",conn)
df2.sort_values(by=['round'])
fig.add_trace(go.Scatter(x=df2['round'], y=smoothTriangle(df2['performance'],smooth_degree),name='Global'),1,2)
The desired results would look like this:
where if clicking in โagent 0โ for example, would hide all the lines in both subplots but agent0 lines.