Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

system/plots.py: Fixed a few bugs in NetworkPlot.

This commit is contained in:
Einar Ryeng 2006-08-01 14:26:33 +00:00
parent b3d681ef16
commit 44b676f726
1 changed files with 8 additions and 10 deletions

View File

@ -511,8 +511,6 @@ class NetworkPlot(Plot):
if not kw.has_key('prog'):
kw['prog'] = 'neato'
if not kw.has_key('pos') or kw['pos']:
print 'graph: ', self.graph, type(self.graph)
print 'prog:', kw['prog']
kw['pos'] = networkx.drawing.nx_pydot.graphviz_layout(self.graph, kw['prog'])
Plot.__init__(self, kw['name'])
@ -554,9 +552,9 @@ class NetworkPlot(Plot):
def rectangle_select_callback(self, x1, y1, x2, y2):
'event1 and event2 are the press and release events'
pos = self.kw['pos']
ydata = zeros((len(pos),),'l')
xdata = zeros((len(pos),),'l')
pos = self.keywords['pos']
ydata = scipy.zeros((len(pos),),'l')
xdata = scipy.zeros((len(pos),),'l')
node_ids = []
c = 0
for name,(x,y) in pos.items():
@ -570,7 +568,7 @@ class NetworkPlot(Plot):
x1, x2 = x2, x1
if y1 > y2:
y1, y2 = y2, y1
index = nonzero((xdata<x1) & (xdata>x2) & (ydata>y1) & (ydata<y2))
index = scipy.nonzero((xdata<x1) & (xdata>x2) & (ydata>y1) & (ydata<y2))
ids = [node_ids[i] for i in index]
self.selection_listener(self.dataset.get_dim_name(0), ids)
@ -585,13 +583,13 @@ class NetworkPlot(Plot):
selected_sizes = [self.node_size[x] for x in selected_nodes]
self.ax.clear()
networkx.draw_networkx_edges(self.graph, self.kw['pos'], edge_list=self.graph.edges(), \
ax=self.ax, *kw)
networkx.draw_networkx_edges(self.graph, edge_list=self.graph.edges(), \
ax=self.ax, **self.keywords)
networkx.draw_networkx_nodes(self.graph, self.kw['pos'], node_list=unselected_nodes, \
networkx.draw_networkx_nodes(self.graph, self.keywords['pos'], node_list=unselected_nodes, \
node_color=unselected_colors, node_size=unselected_sizes, ax=self.ax, *kw)
networkx.draw_networkx_nodes(self.graph, self.kw['pos'], node_list=selected_nodes, \
networkx.draw_networkx_nodes(self.graph, self.keywords['pos'], node_list=selected_nodes, \
node_color='black', node_size=selected_sizes, ax=self.ax, *kw)
self.canvas.draw()