I have a simple graph with a lot of points, so I don't want to show labels for all of them. But I do want to be able to tell which is which, via tooltips.
Is it possible to add/show tooltips using networkx?
Here's my code:
import networkx as nx
g = nx.Graph()
g.add_node(1, label="descriptive label")
nx.draw(g)
I'd like "descriptive label" to show up as a tooltip. Any ideas?
For NetworkX, a graph with more than 100K nodes may be too large. I'll demonstrate that it can handle a network with 187K nodes in this post, but the centrality calculations were prolonged. Luckily, there are some other packages available to help us with even larger graphs.
nbunch. An nbunch is a single node, container of nodes or None (representing all nodes). It can be a list, set, graph, etc.. To filter an nbunch so that only nodes actually in G appear, use G.
To check if the graph is directed you can use nx.is_directed(G) , you can find the documentation here. 'weight' in G[1][2] # Returns true if an attribute called weight exists in the edge connecting nodes 1 and 2.
NetworkX does not have this built in, NetworkX uses matplotlib underneath so you could try the suggestion here:
Point and line tooltips in matplotlib?
and adapt it to your code, hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With