title: Plotly: How to create a dropdown button that groups lines in a line graph?
body: <p>I made a line chart with way too many lines to neatly display and I need to be able to select a grouping variable (Province) and have it just display the lines in that province (I have a Province column in the data that says what Province it belongs to). For example, I would click &quot;Ontario&quot; in the dropdown and just the lines corresponding to Toronto and Ottawa etc would show up. What am I doing wrong?</p>
  <p><a href="https://i.stack.imgur.com/n3u1v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n3u1v.png" alt="enter image description here" /></a></p>
  <pre><code>import plotly.express as px
  import plotly.offline as pyo
  import pandas as pd
  import plotly.graph_objects as go
  
  df = pd.read_csv('....csv')
  
  
  fig_opend = px.line(data_frame = df, x='Round', y='Excess Demand For Plot', title= 'Canada', color='Product' ,
                      hover_name='Service Area Name', hover_data=['Product Number', 'Excess Demand', '(Initial) Supply', 'Aggregate Demand', 'Round'])
  
  
  
  fig_opend.update_yaxes(title = 'Excess Demand')
  
  
  fig_opend.update_layout(margin={&quot;r&quot;:20,&quot;t&quot;:27,&quot;l&quot;:10,&quot;b&quot;:10}, xaxis={'tickformat':',d'})
  
  
  updatemenus = [dict(buttons_open=list([dict(method='update', args=[{'y':[df.loc[df_opend['Areas'] == 'West']]}],),]),direction=&quot;down&quot;,showactive=True)]
  
  fig_opend.update_layout(updatemenus=updatemenus)
  </code></pre>