title: Hidding annotations in Plotly/Python using a button
body: <p>So I have constructed a network plot using Plotly. The output is fine. Now I wanted to add labels per each node of the network. In order to do so I used the Plotly annotations. <code>pos</code> holds the positions as <code>{node_id:(x,y)}</code> for every node in the network; <code>G</code> is my networkx graph.</p>
  
  <pre><code>layoutAnnotationList = []
  for  k,p in pos.items():
      x = p[0]
      y = p[1]
      try:
          text = G.node[k]['hostname']
      except:
          text = k
      layoutAnnotationList.append( { 'x':x, 'y':y, 'text':text } )
  </code></pre>
  
  <p>After this I added the list <code>layoutAnnotationList</code> to the layout itself.</p>
  
  <pre><code>layout = { 'annotations': layoutAnnotationList } 
  </code></pre>
  
  <p>Now, I've read <a href="https://plot.ly/python/custom-buttons/" rel="nofollow noreferrer">this</a> on how to add buttons to the layout, using the <code>relayout</code> method, but I really don't understand how to make those buttons to show or hide the annotations.</p>
  
  <p>I created a <code>layoutButtons</code> list, I got to show them on the webpage, but I'm clueless regarding their functioning.</p>
  
  <pre><code>layout = { 'annotations': layoutAnnotationList, 'updatemenus':layoutButtons }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/7PjqX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7PjqX.png" alt="enter image description here"></a></p>
  
  <p>Any hint on how to use those?</p>
  
  <p>Thanks!</p>