Visualizing graphs with variable edge radius and color.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Visualizing graphs with variable edge radius and color.

Richard Beare
Hi everyone,
I realise that this is a topic that has come up multiple times over
the years. The code from Gael posted at
https://mail.enthought.com/pipermail/enthought-dev/2011-November/030194.html
seems to solve the problem, but I can't get it to work. I have viewed
the graph, stored as a networkx object, in other forms, so I'm
confident that my extraction of edges and node locations is OK.
However running in the most basic way gives the following error. I've
done a lot of searching through examples and can't find anything
suggesting changes that might make this approach invalid. Am I doing
something foolish, have there been changes in API.

I'm using python packages installed in a virtualenv, and the ets
package via pip. vtk is 5.1.

All advice welcome...

eFactory object at 0x18983e90>, trait: point_scalars, old value: , new
value: radius
Traceback (most recent call last):
  File "/gpfs/M2Scratch/Monash002/Pipes/lib/python2.7/site-packages/traits/trait_notifiers.py",
line 317, in call_3
    self.handler( object, trait_name, new )
  File "/gpfs/M2Scratch/Monash002/Pipes/lib/python2.7/site-packages/mayavi/tools/pipe_base.py",
line 197, in _anytrait_changed
    setattr(obj, components[-1], value)
  File "/gpfs/M2Scratch/Monash002/Pipes/lib/python2.7/site-packages/mayavi/core/trait_defs.py",
line 98, in set_value
    value )
TraitError: The 'point_scalars_name' trait of a SetActiveAttribute
instance must be one of ['scalars', ''], but a value of 'radius' <type
'str'> was specified.
---------------------------------------------------------------------------
TraitError                                Traceback (most recent call last)
<ipython-input-24-830576115517> in <module>()
----> 1 pg1(g)

/gpfs/M2Home/rbeare/Projects/BrainArteryNetwork/Python/plot_graph.py in pg1(g)
    163     z=np.array(z)
    164
--> 165     return(plot_graph(adj, x,y,z))

/gpfs/M2Home/rbeare/Projects/BrainArteryNetwork/Python/plot_graph_orig.py
in plot_graph(adjacency, x, y, z, labels, label_size, node_scalar,
node_colormap, node_size, node_color, node_vmin, node_vmax,
edge_color, edge_scalar, edge_colormap, edge_vmin, edge_vmax,
tube_radius, tube_absolute_scale, always_nodes, **kwargs)
     62             tubes = mlab.pipeline.tube(
     63                             mlab.pipeline.set_active_attribute(
---> 64                                 edges_src, point_scalars='radius'),
     65                                 tube_radius=tube_radius,
     66                                 )

/gpfs/M2Scratch/Monash002/Pipes/lib/python2.7/site-packages/mayavi/tools/pipe_base.pyc
in the_function(*args, **kwargs)
     35 def make_function(factory_class):
     36     def the_function(*args, **kwargs):
---> 37         factory = factory_class(*args, **kwargs)
     38         return factory._target
     39

/gpfs/M2Scratch/Monash002/Pipes/lib/python2.7/site-packages/mayavi/tools/pipe_base.pyc
in __init__(self, parent, **kwargs)
    159         # Now calling the traits setter, so that traits handlers are
    160         # called
--> 161         self.set(**traits)
    162         if scene is not None:
    163             scene.disable_render = not self._do_redraw

/gpfs/M2Scratch/Monash002/Pipes/lib/python2.7/site-packages/mayavi/tools/pipe_base.pyc
in set(self, trait_change_notify, **traits)
    176                 if callback is not None:
    177                     callback()
--> 178                 self._anytrait_changed(trait, value)
    179             except TraitError:
    180                 if value==None:

/gpfs/M2Scratch/Monash002/Pipes/lib/python2.7/site-packages/mayavi/tools/pipe_base.pyc
in _anytrait_changed(self, name, value)
    195             components = trait.adapts.split('.')
    196             obj = get_obj(self._target, components[:-1])
--> 197             setattr(obj, components[-1], value)
    198
    199

/gpfs/M2Scratch/Monash002/Pipes/lib/python2.7/site-packages/mayavi/core/trait_defs.pyc
in set_value(object, name, value)
     96             raise TraitError, (object, name,
     97                                "one of %s"%values,
---> 98                                value )
     99         old = super_getattr(object, _name)
    100         super_setattr( object, _name, value )

TraitError: The 'point_scalars_name' trait of a SetActiveAttribute
instance must be one of ['scalars', ''], but a value of 'radius' <type
'str'> was specified.
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev