Closed mabernico closed 3 years ago
Not tested (since I don't know what is in diyNodeSet.csv
) but all you should need is:
def updatePlot(plot_instance):
new_labels = ... # get your label dict
plot_instance.draw_edge_labels(plot_instance.edge_list, new_labels, plot_instance.node_positions)
plot_instance.fig.canvas.draw_idle()
This adds new edge labels and updates existing ones. If you want to delete edge labels, you will have to remove them explicitly. The artists are stored in a dictionary that maps edges to artists.
for edge in edge_labels_to_remove:
plot_instance.edge_label_artists[edge].remove() # delete artist
del plot_instance.edge_label_artists[edge] # delete reference
@mabernico Does this solve your issue? Then I will close this thread (or you can if you want to).
@paulbrodersen Thanks for this solution! It worked like a charm and helped me see a bit more about how to hook into various layers.
I am working on a visualization of a network that includes moveable nodes with edge labels that are updated by streaming data. Currently I am using randint to update a pandas dataframe while I work on the plotting.
The current code can generate the nodes and allows them to move and also updates the edge labels, but it feels "clunky" and every once in a while the plot flashes the axes (which I do not want to see). I believe this is just an artifact of clearing and regenerating the plot. I can't seem to find a good hook in netgraph to simply refresh graph without doing a clear and redraw which will inevitably get worse as the network grows. Any ideas on how to make this smoother?
Here is the current code: