# Plotly.py difficultly in selecting/ deselecting individual traces for the legend with multiple subplots

**URL:** <https://community.plotly.com/t/plotly-py-difficultly-in-selecting-deselecting-individual-traces-for-the-legend-with-multiple-subplots/47471>\
**Category:** 📊 Plotly Python\
**Created:** [November 23, 2020, 2:44pm UTC](https://community.plotly.com/t/plotly-py-difficultly-in-selecting-deselecting-individual-traces-for-the-legend-with-multiple-subplots/47471 "2020-11-23T14:44:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![benprint1](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@benprint1](https://community.plotly.com/u/benprint1)\
**Post date:** [November 23, 2020, 2:44pm UTC](https://community.plotly.com/t/plotly-py-difficultly-in-selecting-deselecting-individual-traces-for-the-legend-with-multiple-subplots/47471/1 "2020-11-23T14:44:02Z")

</div>

Hi, I am having an issue with formatting my legend items with plotly subplots. I have 9 timeseries subplots with each containing three traces. Most of these traces are unique and need to be displayed in the legend, however others are duplicated throughout the subplots and so I would like to only represent them in the legend once.

Unfortunately, I have not been able to find a way for this to work using online examples - most of them rely on using the legendgroup = “xxx” or selectively entering showlegend=False into the appropriate traces, however it seems that using fig = make\_subplots (rows = x, cols = y) instead of fig. go Figure() causes both to not be recognised (e.g. “_add\_trace() got an unexpected keyword argument ‘legendgroup’_” ).

I was wondering whether anyone knew of a way to get around this when using subplots? Currently I am defining traces individually i.e.

fig.add\_trace(go.Scatter( x=date, y=timeseries1, etc etc)  
fig.add\_trace(go.Scatter( x=date, y=timeseries2, etc etc)

and the following isn’t recognised by plotly:

- This example causes an “unexpected keyboard argument error”

fig.add\_trace(go.Scatter( x=date, y=timeseries1, showlegend=False)  
fig.add\_trace(go.Scatter( x=date, y=timeseries2)

- This example again causes an “unexpected keyboard argument error”

fig.add\_trace(go.Scatter( x=date, y=timeseries1, legendgroup=“a”)  
fig.add\_trace(go.Scatter( x=date, y=timeseries2, legendgroup=“b”)

Any help would be greatly appreciated!
