I'm trying to use networkx to draw circles at particular positions. Each of the circle I want to draw has a set of coordinates, and a radius.
I can set the coordinates easily:
import networkx as nx
import matplotlib.pyplot as plt
positions = [(0, 0), (36.439507534009273, 0.0),
(36.439507534009273, -36.439507534009273),
(36.439507534009273, -72.879015068018546),
(0.0, -72.879015068018546),
(2.231276313201516e-15, -109.31852260202781),
(4.4625526264030319e-15, -145.75803013603709),
(36.43950753400928, -145.75803013603709),
(36.43950753400928, -182.19753767004639)]
G = nx.Graph()
pos = dict()
for i, couple in enumerate(positions):
G.add_node(i)
print(couple)
pos[i] = couple
print(G.number_of_nodes())
fig = plt.figure(1)
nodes = nx.draw_networkx_nodes(G, pos)
nx.draw_networkx_edges(G, pos)
plt.axis('equal')
plt.savefig('drawing.png', bbox_inches='tight', dpi=400)
plt.clf()
But I can't set the radius properly. The positions in my example are in millimetres, and the radii of my circles will be as well.
I can set the "size of the nodes" with node_size
, but I don't think I can correlate node_size
to my radii. For example, the default for node_size
is 300, and I don't know what it corresponds to.
If I have a circle at position let's say (20, 20), and the radius is 20, I should have a circle ranging from 0 to 40 (in x).
How can I achieve that with networkx ?