title: Populating plot legend with only unique trace names with Plotly add_trace go.scatter for-loop
body: <p>My current code uses a for-loop to populate plotly line plots, generally with hundreds trends being added: </p>
  
  <pre><code>fig.add_trace(go.Scatter(
          x=x_axis_data,
          y=y_axis_data,
          mode='lines',
          legendgroup="Data Group 1",
          name='Data',
          line=dict(
              color='royalblue',
              dash ='dot',
              width=3.5,
          )
      ),row=1,col=j)   
  </code></pre>
  
  <p>Once all of my traces are added, I use the following (which I understand is the default setting anyway):</p>
  
  <pre><code> fig.update_layout(showlegend=True)
  </code></pre>
  
  <p>My issue is that in the plot legend, I end up with a legend title for every trace when all I want is to show either: </p>
  
  <p>1) unique trace names only (no duplicates), or 
  2) the legend group name (only 1 time each, not one per trend added). </p>
  
  <p>Is there a way to do this without adding dummy traces, etc.? FYI, I have reviewed the following resource: <a href="https://plotly.com/python/legend/" rel="nofollow noreferrer">https://plotly.com/python/legend/</a>. This would work as-is if I was not using a for-loop to populate multiple traces with one fig.add_trace function, but I cannot get it to do what I want with the legend with the for-loop population. Thanks.</p>