title: Update visibility of Traces with fig.update_layout Plotly
body: <p>Following on from this quesiton: <a href="https://stackoverflow.com/questions/66226542/set-sqrt-as-yaxis-scale-from-dropdown-or-button-python-plotly">Set sqrt as yaxis scale from dropdown or button-Python/Plotly</a></p>
  <p>I want to :</p>
  <ol>
  <li>Define a plot with all traces: visible = False</li>
  </ol>
  <pre class="lang-py prettyprint-override"><code>fig.add_scatter(mode=&quot;markers&quot;, x=df[&quot;gdpPercap&quot;], y=df[&quot;lifeExp&quot;], visible = False) #set both vis to False 
  fig.add_scatter(mode=&quot;markers&quot;, x=df[&quot;gdpPercap&quot;], y=np.sqrt(df[&quot;lifeExp&quot;]), visible = False)
  </code></pre>
  <ol start="2">
  <li>Create an update button that can make trace1 or trace2 become visbile</li>
  </ol>
  <pre class="lang-py prettyprint-override"><code># buttons for updatemenu
  buttons = [dict(method='restyle',
                  label='linear',
                  visible=True,
                  args=[{'label': 'linear',
                         'visible':[True, False],
                        }
                       ]),.....
           
   um = [{'buttons':buttons,
        'direction': 'down'}
        ]
  
  fig.update_layout(updatemenus=um)
  </code></pre>
  <ol start="3">
  <li>Set inital condition to be trace1 = visible, trace2 =invisible</li>
  </ol>
  <pre class="lang-py prettyprint-override"><code>fig.update_layout(dict(args = {&quot;visible&quot;: [True, False]}))
  </code></pre>
  <p>The first 2 points have been solved.
  I cannot find a way to preset the initial display conditions. In this example i could easily change the visibility while creating the traces, but in my real problem it would be harder.</p>
  <p>This is the full example:</p>
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  import plotly.graph_objects as go
  import plotly.express as px
  df = px.data.gapminder().query(&quot;year == 2007&quot;)
  
  # figure setup
  fig = go.Figure()
  fig.add_scatter(mode=&quot;markers&quot;, x=df[&quot;gdpPercap&quot;], y=df[&quot;lifeExp&quot;], visible = False) #set both vis to False 
  fig.add_scatter(mode=&quot;markers&quot;, x=df[&quot;gdpPercap&quot;], y=np.sqrt(df[&quot;lifeExp&quot;]), visible = False)
  
  # buttons for updatemenu
  buttons = [dict(method='restyle',
                  label='linear',
                  visible=True,
                  args=[{'label': 'linear',
                         'visible':[True, False],
                        }
                       ]),
             dict(method='restyle',
                  label='sqrt',
                  visible=True,
                  args=[{'label': 'linear',
                         'visible':[False, True],
                        }
                       ])]
             
  # specify updatemenu        
  um = [{'buttons':buttons,
        'direction': 'down'}
        ]
  
  fig.update_layout(updatemenus=um)
  
  
   #Update plot before showing to make 1st trace visible COMMENTED OUT CODE NOT WORKING 
  # fig.update_layout(dict(args = {&quot;visible&quot;: [True, False]}))
  
  fig.show()
  </code></pre>