Skip to content

Commit

Permalink
Merge pull request #14 from benmaier/ulfaslak-patch-2
Browse files Browse the repository at this point in the history
Change node position to be separate key-value pairs as opposed to `pos` vector
  • Loading branch information
benmaier committed Apr 10, 2019
2 parents 6c52634 + abd354e commit 94c400d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions netwulf/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def bind_positions_to_network(network, network_properties):
interactive visualization.
"""

x = { node['id']: node['pos'][0] for node in network_properties['nodes'] }
y = { node['id']: node['pos'][1] for node in network_properties['nodes'] }
x = { node['id']: node['x'] for node in network_properties['nodes'] }
y = { node['id']: node['y'] for node in network_properties['nodes'] }
nx.set_node_attributes(network, x, 'x')
nx.set_node_attributes(network, y, 'y')

Expand Down Expand Up @@ -78,8 +78,8 @@ def draw_netwulf(network_properties, fig=None, ax=None, figsize=None):
.. code:: python
ax.text(
network_properties['nodes'][0]['pos'][0],
network_properties['nodes'][0]['pos'][1],
network_properties['nodes'][0]['x'],
network_properties['nodes'][0]['y'],
network_properties['nodes'][0]['id']
)
Expand Down Expand Up @@ -144,15 +144,15 @@ def draw_netwulf(network_properties, fig=None, ax=None, figsize=None):

# filter out node positions for links
width = network_properties['xlim'][1] - network_properties['xlim'][0]
pos = { node['id']: np.array(node['pos']) for node in network_properties['nodes'] }
pos = { node['id']: np.array([node['x'], node['y']]) for node in network_properties['nodes'] }

lines = []
linewidths = []
for link in network_properties['links']:
u, v = link['link']
lines.append([
[pos[u][0],pos[v][0]],
[pos[u][1],pos[v][1]]
[pos[u][0], pos[v][0]],
[pos[u][1], pos[v][1]]
])
linewidths.append(link['width']/width*axwidth)

Expand All @@ -175,7 +175,7 @@ def draw_netwulf(network_properties, fig=None, ax=None, figsize=None):
node_colors = []

for node in network_properties['nodes']:
XY.append( node['pos'] )
XY.append([node['x'], node['y']])
# size has to be given in points**2
size.append( 2*node['radius'] )
node_colors.append(node['color'])
Expand Down

0 comments on commit 94c400d

Please sign in to comment.