|
6 | 6 | # Maintainer: |
7 | 7 | # Created: Fri Jul 12 11:53:50 2013 (+0530) |
8 | 8 | # Version: |
9 | | -# Last-Updated: Thu Aug 11 11:59:17 2016 (-0400) |
| 9 | +# Last-Updated: Thu Aug 11 17:21:24 2016 (-0400) |
10 | 10 | # By: Subhasis Ray |
11 | | -# Update #: 746 |
| 11 | +# Update #: 781 |
12 | 12 | # URL: |
13 | 13 | # Keywords: |
14 | 14 | # Compatibility: |
@@ -194,43 +194,13 @@ def displayGraph(self, g, label=False): |
194 | 194 | if len(sizes) == 0: |
195 | 195 | print('Empty graph for cell. Make sure proto file has `*asymmetric` on top. I cannot handle symmetric compartmental connections') |
196 | 196 | return |
197 | | - weights = np.array([g.edge[e[0]][e[1]]['weight'] for e in g.edges()]) |
198 | | - try: |
199 | | - pos = nx.graphviz_layout(g, prog='twopi') |
200 | | - except (NameError, AttributeError) as e: |
201 | | - pos = nx.spectral_layout(g) |
202 | | - xmin, ymin, xmax, ymax = 1e9, 1e9, -1e9, -1e9 |
203 | | - for p in pos.values(): |
204 | | - if xmin > p[0]: |
205 | | - xmin = p[0] |
206 | | - if xmax < p[0]: |
207 | | - xmax = p[0] |
208 | | - if ymin > p[1]: |
209 | | - ymin = p[1] |
210 | | - if ymax < p[1]: |
211 | | - ymax = p[1] |
212 | | - edge_widths = 10.0 * weights / max(weights) |
213 | 197 | node_colors = ['k' if x in axon else 'gray' for x in g.nodes()] |
214 | 198 | lw = [1 if n.endswith('comp_1') else 0 for n in g.nodes()] |
215 | | - print('Edge widths:', edge_widths) |
216 | 199 | self.axes.clear() |
217 | | - self.axes.set_xlim((xmin-10, xmax+10)) |
218 | | - self.axes.set_ylim((ymin-10, ymax+10)) |
219 | | - for ii, e in enumerate(g.edges()): |
220 | | - p0 = pos[e[0]] |
221 | | - p1 = pos[e[1]] |
222 | | - a = patches.FancyArrow(p0[0], p0[1], p1[0] - p0[0], p1[1] - p0[1], width=edge_widths[ii], head_width=0.0, axes=self.axes, ec='none', fc='black') |
223 | | - self.axes.add_patch(a) |
224 | | - for ii, n in enumerate(g.nodes()): |
225 | | - if n in axon: |
226 | | - ec = 'black' |
227 | | - elif n.endswith('comp_1'): |
228 | | - ec = 'red' |
229 | | - else: |
230 | | - ec = 'none' |
231 | | - c = patches.Circle(pos[n], radius=sizes[ii], axes=self.axes, ec=ec, fc='gray', alpha=0.8) |
232 | | - self.axes.add_patch(c) |
233 | | - self.canvas.draw() |
| 200 | + try: |
| 201 | + nx.draw_graphviz(g, ax=self.axes, prog='twopi', node_color=node_colors, lw=lw) |
| 202 | + except (NameError, AttributeError) as e: |
| 203 | + nx.draw_spectral(g, ax=self.axes, node_color=node_colors, lw=lw, with_labels=False, ) |
234 | 204 |
|
235 | 205 |
|
236 | 206 | class CellView(QtGui.QWidget): |
|
0 commit comments