visbrain.objects.VectorObj¶
- class visbrain.objects.VectorObj(name, arrows, data=None, inferred_data=False, select=None, color='black', dynamic=None, dynamic_order=1, dynamic_orientation='ascending', line_width=5.0, arrow_size=10.0, arrow_type='stealth', arrow_coef=1.0, arrow_norm=(5.0, 20.0), antialias=False, cmap='viridis', clim=None, vmin=None, under='gray', vmax=None, over='red', transform=None, parent=None, verbose=None, _z=-10.0, **kw)[source][source]¶
Create a vector object.
- Parameters:
- namestring
Name of the vector object.
- arrowsarray_like, tuple, list
The position of arrows. Use either :
A list (or tuple) of two arrays with identical shapes (N, 3). The first array specify the (x, y, z) position where arrows start and the second the (x, y, z) position of the end of each arrow.
Alternatively to the point above, an array of type [(‘start’, float, 3), (‘end’, float, 3)] can also be used.
An array of type [(‘vertices’, float, 3), (‘normals’, float, 3)]. This method use the normals to vertices to inferred the arrow locations. In addition, if data is not None, data is used to inferred the arrow length.
- dataarray_like | None
Attach some data to each vector. This data can be used to inferred the color.
- inferred_databool | False
If the arrows input use the (start, end) method and if inferred_data is set to True, the magnitude of each vector is used as data.
- selectarray_like | None
An array of boolean values to select some specifics arrows.
- colorarray_like/tuple/string | ‘black’
If no data are provided, use this parameter to set a unique color for all vectors.
- dynamictuple | None
Use a dynamic transparency method. The dynamic input must be a tuple of two float between [0, 1]. Vectors with stronger associated data are going to be set more opaque.
- dynamic_orderint | 1
If 1, the dynamic transparency is linearly modulated by the connectivity. If 2, the transparency follow a x**2 curve etc.
- dynamic_orientationstr | ‘ascending’
Define the transparency behavior :
‘ascending’ : from translucent to opaque
‘center’ : from opaque to translucent and finish by opaque
‘descending’ ; from opaque to translucent
- line_widthfloat | 5.
Line width of each vector.
- arrow_sizefloat | 10.
Size of the arrow-head.
- arrow_typestring | ‘stealth’
The arrow-head type. Use either ‘stealth’, ‘curved’, ‘angle_30’, ‘angle_60’, ‘angle_90’, ‘triangle_30’, ‘triangle_60’, ‘triangle_90’ or ‘inhibitor_round’.
- arrow_coeffloat | 1.
Use this coefficient to define longer arrows. Must be a float superior to 1.
- arrow_normtuple | (5., 20.)
Control arrow length for arrows defined using vertices and normals.
- antialiasbool | False
Use smoothed lines.
- cmapstring | ‘viridis’
The colormap to use (if data is not None).
- climtuple | None
Colorbar limits. If None, the (max, min) of data is used (if data is not None).
- vminfloat | None
Minimum threshold (if data is not None).
- understring | ‘gray’
Color for values under vmin (if data is not None).
- vmaxfloat | None
Maximum threshold (if data is not None).
- overstring | ‘red’
Color for values over vmax (if data is not None).
- transformVisPy.visuals.transforms | None
VisPy transformation to set to the parent node.
- parentVisPy.parent | None
Markers object parent.
- verbosestring
Verbosity level.
- _zfloat | 10.
In case of (n_sources, 2) use _z to specify the elevation.
- kwdict | {}
Optional arguments are used to control the colorbar (See
ColorbarObj
).
Notes
List of supported shortcuts :
s : save the figure
<delete> : reset camera
Examples
>>> import numpy as np >>> from visbrain.objects import VectorObj >>> n_vector = 10 >>> arrows = [np.random.rand(n_vector, 3), np.random.rand(n_vector, 3)] >>> data = np.random.uniform(-10, 10, (n_vector)) >>> v = VectorObj('Vector', arrows, data=data, antialias=True) >>> v.preview(axis=True)
Methods
__init__
(name, arrows[, data, ...])Init.
animate
([step, interval, iterations])Animate the object.
copy
()Get a copy of the object.
Tree description.
preview
([bgcolor, axis, xyz, show, obj, ...])Previsualize the result.
record_animation
(name[, n_pic, bgcolor])Record an animated object and save as a *.gif file.
render
()Render the canvas.
screenshot
(saveas[, print_size, dpi, unit, ...])Take a screeshot of the scene.
set_shortcuts_to_canvas
(canvas)Set shortcuts to a VisbrainCanvas.
to_dict
()Return a dictionary of all colorbar args.
to_kwargs
([addisminmax])Return a dictionary for input arguments.
update
()Fonction to run when an update is needed.
update_from_dict
(kwargs)Update attributes from a dictionary.