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. pos holds the positions as {node_id:(x,y)} for every node in the network; G is my networkx graph.
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 } )
After this I added the list layoutAnnotationList to the layout itself.
layout = { 'annotations': layoutAnnotationList }
Now, I've read this on how to add buttons to the layout, using the relayout method, but I really don't understand how to make those buttons to show or hide the annotations.
I created a layoutButtons list, I got to show them on the webpage, but I'm clueless regarding their functioning.
layout = { 'annotations': layoutAnnotationList, 'updatemenus':layoutButtons }
Any hint on how to use those?
Thanks!
