Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using draw_networkx(), How to show multiple drawing windows?

Tags:

networkx

The following code will create only one window at a time, the second window will only show when the first one is closed by the user.

How to show them at the same time with different titles?

nx.draw_networkx(..a..)
nx.draw_networkx(..b..)
like image 238
Matt Avatar asked Jun 23 '11 23:06

Matt


People also ask

What is used to visualize NetworkX graphs?

NetworkX has its own drawing module which provides multiple options for plotting. Below we can find the visualization for some of the draw modules in the package. Using any of them is fairly easy, as all you need to do is call the module and pass the G graph variable and the package does the rest.

How many nodes can NetworkX handle?

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.

How do you create a directed graph in Python?

Add the nodes from any container (a list, dict, set or even the lines from a file or the nodes from another graph). In addition to strings and integers any hashable Python object (except None) can represent a node, e.g. a customized node object, or even another Graph. Edges: G can also be grown by adding edges.


1 Answers

It works the same as making other plots with Matplotlib. Use the figure() command to switch to a new figure.

import networkx as nx
import matplotlib.pyplot as plt

G=nx.cycle_graph(4)
H=nx.path_graph(4)

plt.figure(1)
nx.draw(G)
plt.figure(2)
nx.draw(H)

plt.show()
like image 104
Aric Avatar answered Nov 12 '22 07:11

Aric