Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to show tooltips on a networkx graph?

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?

like image 969
Jason Sundram Avatar asked Mar 08 '11 18:03

Jason Sundram


People also ask

Can NetworkX handle large graphs?

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.

What is Nbunch in NetworkX?

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.

How can you tell if a graph is directed by NetworkX?

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.


1 Answers

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.

like image 163
EdChum Avatar answered Oct 01 '22 03:10

EdChum