This module provides a library of Visual classes, which are drawable objects intended to encapsulate simple graphic objects such as lines, meshes, points, 2D shapes, images, text, etc.
These classes define only the OpenGL machinery and connot be used directly in a scenegraph. For scenegraph use, see the complementary Visual+Node classes defined in vispy.scene.
vispy.visuals.
ArrowVisual
(pos=None, color=(0.5, 0.5, 0.5, 1), width=1, connect='strip', method='gl', antialias=False, arrows=None, arrow_type='stealth', arrow_size=None, arrow_color=(0.5, 0.5, 0.5, 1))[source]¶Bases: vispy.visuals.line.line.LineVisual
Arrow visual
A special line visual which can also draw optional arrow heads at the specified vertices.
You add an arrow head by specifying two vertices v1 and v2 which represent the arrow body. This visual will draw an arrow head using v2 as center point, and the orientation of the arrow head is automatically determined by calculating the direction vector between v1 and v2.
Parameters: | pos : array
color : Color, tuple, or array
width:
connect : str or array
method : str
antialias : bool
arrows : array
arrow_type : string
arrow_size : float
arrow_color : Color, tuple, or array
|
---|
set_data
(pos=None, color=None, width=None, connect=None, arrows=None)[source]¶Set the data used for this visual
Parameters: | pos : array
color : Color, tuple, or array
width:
connect : str or array
arrows : array
|
---|
vispy.visuals.
AxisVisual
(pos=None, domain=(0.0, 1.0), tick_direction=(-1.0, 0.0), scale_type='linear', axis_color=(1, 1, 1), tick_color=(0.7, 0.7, 0.7), text_color='w', minor_tick_length=5, major_tick_length=10, tick_width=2, tick_label_margin=5, tick_font_size=8, axis_width=3, axis_label=None, axis_label_margin=35, axis_font_size=10, font_size=None, anchors=None)[source]¶Bases: vispy.visuals.visual.CompoundVisual
Axis visual
Parameters: | pos : array
domain : tuple
tick_direction : array
scale_type : str
axis_color : tuple
tick_color : tuple
text_color : Color
minor_tick_length : float
major_tick_length : float
tick_width : float
tick_label_margin : float
tick_font_size : float
axis_width : float
axis_label : str
axis_label_margin : float
axis_font_size : float
font_size : float
anchors : iterable
|
---|
vispy.visuals.
BaseVisual
(vshare=None)[source]¶Bases: vispy.util.frozen.Frozen
Superclass for all visuals.
This class provides:
- A TransformSystem.
- Two events: update and bounds_change.
- Minimal framework for creating views of the visual.
- A data structure that is shared between all views of the visual.
- Abstract draw, bounds, attach, and detach methods.
Parameters: | vshare : instance of VisualShare | None
|
---|
Notes
When used in the scenegraph, all Visual classes are mixed with vispy.scene.Node in order to implement the methods, attributes and capabilities required for their usage within it.
This subclasses Frozen so that subclasses can easily freeze their properties.
attach
(filt, view=None)[source]¶Attach a Filter to this visual.
Each filter modifies the appearance or behavior of the visual.
Parameters: | filt : object
view : instance of VisualView | None
|
---|
bounds
(axis, view=None)[source]¶Get the bounds of the Visual
Parameters: | axis : int
view : instance of VisualView
|
---|
detach
(filt, view=None)[source]¶Detach a filter.
Parameters: | filt : object
view : instance of VisualView | None
|
---|
get_transform
(map_from='visual', map_to='render')[source]¶Return a transform mapping between any two coordinate systems.
Parameters: | map_from : str
map_to : str
|
---|
vispy.visuals.
BoxVisual
(width=1, height=1, depth=1, width_segments=1, height_segments=1, depth_segments=1, planes=None, vertex_colors=None, face_colors=None, color=(0.5, 0.5, 1, 1), edge_color=None, **kwargs)[source]¶Bases: vispy.visuals.visual.CompoundVisual
Visual that displays a box.
Parameters: | width : float
height : float
depth : float
width_segments : int
height_segments : float
depth_segments : float
planes: array_like
vertex_colors : ndarray
face_colors : ndarray
color : Color
edge_color : tuple or Color
|
---|
border
¶The vispy.visuals.MeshVisual that used to draw the border.
mesh
¶The vispy.visuals.MeshVisual that used to fill in.
vispy.visuals.
ColorBarVisual
(cmap, orientation, size, pos=[0, 0], label_str='', label_color='black', clim=(0.0, 1.0), border_width=1.0, border_color='black', **kwargs)[source]¶Bases: vispy.visuals.visual.CompoundVisual
Visual subclass displaying a colorbar
Parameters: | cmap : str | vispy.color.ColorMap
orientation : {‘left’, ‘right’, ‘top’, ‘bottom’}
size : (major_axis_length, minor_axis_length)
pos : tuple (x, y)
label_str : str
label_color : str | vispy.color.Color
clim : tuple (min, max)
border_width : float (in px)
border_color : str | vispy.color.Color
|
---|
border_color
¶The color of the border around the ColorBar in pixels
border_width
¶The width of the border around the ColorBar in pixels
clim
¶The data limits of the Colorbar
Returns: | clim: tuple(min, max) |
---|
cmap
¶The colormap of the Colorbar
label
¶The vispy.visuals.TextVisual associated with the label
orientation
¶The orientation of the ColorBar
pos
¶The position of the text anchor in the local coordinate frame
size
¶The size of the ColorBar
Returns: | size: (major_axis_length, minor_axis_length)
|
---|
ticks
¶The vispy.visuals.TextVisual associated with the ticks
Returns: | ticks: [vispy.visual.TextVisual]
|
---|
vispy.visuals.
CompoundVisual
(subvisuals)[source]¶Bases: vispy.visuals.visual.BaseVisual
Visual consisting entirely of sub-visuals.
To the user, a compound visual behaves exactly like a normal visual–it has a transform system, draw() and bounds() methods, etc. Internally, the compound visual automatically manages proxying these transforms and methods to its sub-visuals.
Parameters: | subvisuals : list of BaseVisual instances
|
---|
add_subvisual
(visual)[source]¶Add a subvisual
Parameters: | visual : instance of Visual
|
---|
attach
(filt, view=None)[source]¶Attach a Filter to this visual
Each filter modifies the appearance or behavior of the visual.
Parameters: | filt : object
view : instance of VisualView | None
|
---|
detach
(filt, view=None)[source]¶Detach a filter.
Parameters: | filt : object
view : instance of VisualView | None
|
---|
remove_subvisual
(visual)[source]¶Remove a subvisual
Parameters: | visual : instance of Visual
|
---|
vispy.visuals.
CubeVisual
(size=1.0, vertex_colors=None, face_colors=None, color=(0.5, 0.5, 1, 1), edge_color=None, **kwargs)[source]¶Bases: vispy.visuals.box.BoxVisual
Visual that displays a cube or cuboid
Parameters: | size : float or tuple
vertex_colors : ndarray
face_colors : ndarray
color : Color
edge_color : tuple or Color
|
---|
vispy.visuals.
EllipseVisual
(center=None, color='black', border_color=None, border_width=1, radius=(0.1, 0.1), start_angle=0.0, span_angle=360.0, num_segments=100, **kwargs)[source]¶Bases: vispy.visuals.polygon.PolygonVisual
Displays a 2D ellipse
Parameters: | center : array
color : instance of Color
border_color : instance of Color
border_width: float
radius : float | tuple
start_angle : float
span_angle : float
num_segments : int
**kwargs : dict
|
---|
center
¶The center of the ellipse
num_segments
¶The number of segments in the ellipse.
radius
¶The start radii of the ellipse.
span_angle
¶The angular span of the ellipse.
start_angle
¶The start start_angle of the ellipse.
vispy.visuals.
GraphVisual
(adjacency_mat=None, directed=False, layout=None, animate=False, line_color=None, line_width=None, arrow_type=None, arrow_size=None, node_symbol=None, node_size=None, border_color=None, face_color=None, border_width=None)[source]¶Bases: vispy.visuals.visual.CompoundVisual
Visual for displaying graphs or networks.
Parameters: | adjacency_mat : array or sparse
directed : bool
layout : str
animate : bool
line_color : str or
line_width : number
arrow_type : str
arrow_size : number
node_symbol : string
node_size : number
border_color : str or
face_color : str or
border_width : number
|
---|
See also
vispy.visuals.
GridLinesVisual
(scale=(1, 1), color='w')[source]¶Bases: vispy.visuals.image.ImageVisual
Displays regularly spaced grid lines in any coordinate system and at any scale.
Parameters: | scale : tuple
color : Color
|
---|
vispy.visuals.
GridMeshVisual
(xs, ys, zs, colors=None, shading='smooth', **kwargs)[source]¶Bases: vispy.visuals.mesh.MeshVisual
Displays a mesh in a Cartesian grid about x,y,z coordinates.
This makes it simple to generate a mesh from e.g. the output of numpy.meshgrid.
All arguments are optional, though they can be changed individually later with the set_data method.
Parameters: | xs : ndarray
ys : ndarray
zs : ndarray
colors : ndarray | None
shading : str | None
**kwargs :
|
---|
set_data
(xs=None, ys=None, zs=None, colors=None)[source]¶Update the mesh data.
Parameters: | xs : ndarray | None
ys : ndarray | None
zs : ndarray | None
colors : ndarray | None
|
---|
vispy.visuals.
HistogramVisual
(data, bins=10, color='w', orientation='h')[source]¶Bases: vispy.visuals.mesh.MeshVisual
Visual that calculates and displays a histogram of data
Parameters: | data : array-like
bins : int | array-like
color : instance of Color
orientation : {‘h’, ‘v’}
|
---|
vispy.visuals.
ImageVisual
(data=None, method='auto', grid=(1, 1), cmap='viridis', clim='auto', interpolation='nearest', **kwargs)[source]¶Bases: vispy.visuals.visual.Visual
Visual subclass displaying an image.
Parameters: | data : ndarray
method : str
grid: tuple (rows, cols)
cmap : str | ColorMap
clim : str | tuple
interpolation : str
**kwargs : dict
|
---|
Notes
The colormap functionality through cmap
and clim
are only used
if the data are 2D.
vispy.visuals.
InfiniteLineVisual
(pos=None, color=(1.0, 1.0, 1.0, 1.0), vertical=True, **kwargs)[source]¶Bases: vispy.visuals.visual.Visual
Infinite horizontal or vertical line for 2D plots.
Parameters: | pos : float
color : list, tuple, or array
vertical:
|
---|
vispy.visuals.
IsocurveVisual
(data=None, levels=None, color_lev=None, clim=None, **kwargs)[source]¶Bases: vispy.visuals.line.line.LineVisual
Displays an isocurve of a 2D scalar array.
Parameters: | data : ndarray | None
levels : ndarray, shape (Nlev,) | None
color_lev : Color, colormap name, tuple, list or array
clim : tuple
**kwargs : dict
|
---|
levels
¶The threshold at which the isocurve is constructed from the 2D data.
vispy.visuals.
IsolineVisual
(vertices=None, tris=None, data=None, levels=None, color_lev=None, **kwargs)[source]¶Bases: vispy.visuals.line.line.LineVisual
Isocurves of a tri mesh with data at vertices at different levels.
Parameters: | vertices : ndarray, shape (Nv, 3) | None
tris : ndarray, shape (Nf, 3) | None
data : ndarray, shape (Nv,) | None
levels : ndarray, shape (Nlev,) | None
color_lev : Color, tuple, colormap name or array
**kwargs : dict
|
---|
data
¶The mesh data
levels
¶The threshold at which the isocurves are constructed from the data.
vispy.visuals.
IsosurfaceVisual
(data=None, level=None, vertex_colors=None, face_colors=None, color=(0.5, 0.5, 1, 1), **kwargs)[source]¶Bases: vispy.visuals.mesh.MeshVisual
Displays an isosurface of a 3D scalar array.
Parameters: | data : ndarray | None
level: float | None
vertex_colors : ndarray | None
face_colors : ndarray | None
color : ndarray | None
**kwargs : dict
|
---|
level
¶The threshold at which the isosurface is constructed from the 3D data.
set_data
(data=None, vertex_colors=None, face_colors=None, color=None)[source]¶Set the scalar array data
Parameters: | data : ndarray
vertex_colors : array-like | None
face_colors : array-like | None
color : instance of Color
|
---|
vispy.visuals.
LinePlotVisual
(data=None, color='k', symbol=None, line_kind='-', width=1.0, marker_size=10.0, edge_color='k', face_color='w', edge_width=1.0, connect='strip')[source]¶Bases: vispy.visuals.visual.CompoundVisual
Visual displaying a plot line with optional markers.
Parameters: | data : array-like
color : instance of Color
symbol : str
line_kind : str
width : float
marker_size : float
edge_color : instance of Color
face_color : instance of Color
edge_width : float
connect : str | array
**kwargs : keyword arguments
|
---|
See also
LineVisual
, MarkersVisual
, marker_types
Examples
All of these syntaxes will work:
>>> LinePlotVisual(y_vals)
>>> LinePlotVisual(x_vals, y_vals)
>>> LinePlotVisual(xy_vals)
vispy.visuals.
LineVisual
(pos=None, color=(0.5, 0.5, 0.5, 1), width=1, connect='strip', method='gl', antialias=False)[source]¶Bases: vispy.visuals.visual.CompoundVisual
Line visual
Parameters: | pos : array
color : Color, tuple, or array
width:
connect : str or array
method : str
antialias : bool
|
---|
method
¶The current drawing method
set_data
(pos=None, color=None, width=None, connect=None)[source]¶Set the data used to draw this visual.
Parameters: | pos : array
color : Color, tuple, or array
width:
connect : str or array
|
---|
vispy.visuals.
LinearRegionVisual
(pos=None, color=[1.0, 1.0, 1.0, 1.0], vertical=True, **kwargs)[source]¶Bases: vispy.visuals.visual.Visual
Infinite horizontal or vertical region for 2D plots.
Parameters: | pos : list, tuple or numpy array
color : list, tuple, or array
vertical:
|
---|
set_data
(pos=None, color=None)[source]¶Set the data
Parameters: | pos : list, tuple or numpy array
color : list, tuple, or array
|
---|
vispy.visuals.
MarkersVisual
(**kwargs)[source]¶Bases: vispy.visuals.visual.Visual
Visual displaying marker symbols.
set_data
(pos=None, symbol='o', size=10.0, edge_width=1.0, edge_width_rel=None, edge_color='black', face_color='white', scaling=False)[source]¶Set the data used to display this visual.
Parameters: | pos : array
symbol : str
size : float or array
edge_width : float | None
edge_width_rel : float | None
edge_color : Color | ColorArray
face_color : Color | ColorArray
scaling : bool
|
---|
Notes
Allowed style strings are: disc, arrow, ring, clobber, square, diamond, vbar, hbar, cross, tailed_arrow, x, triangle_up, triangle_down, and star.
vispy.visuals.
MeshVisual
(vertices=None, faces=None, vertex_colors=None, face_colors=None, color=(0.5, 0.5, 1, 1), vertex_values=None, meshdata=None, shading=None, mode='triangles', **kwargs)[source]¶Bases: vispy.visuals.visual.Visual
Mesh visual
Parameters: | vertices : array-like | None
faces : array-like | None
vertex_colors : array-like | None
face_colors : array-like | None
color : instance of Color
vertex_values : array-like | None
meshdata : instance of MeshData | None
shading : str | None
mode : str
**kwargs : dict
|
---|
ambient_light_color
¶The ambient light color
color
¶The uniform color for this mesh
light_dir
¶The light direction
mesh_data
¶The mesh data
mode
¶The triangle mode used to draw this mesh.
Options are:
- ‘triangles’: Draw one triangle for every three vertices (eg, [1,2,3], [4,5,6], [7,8,9)
- ‘triangle_strip’: Draw one strip for every vertex excluding the first two (eg, [1,2,3], [2,3,4], [3,4,5])
- ‘triangle_fan’: Draw each triangle from the first vertex and the last two vertices (eg, [1,2,3], [1,3,4], [1,4,5])
set_data
(vertices=None, faces=None, vertex_colors=None, face_colors=None, color=None, vertex_values=None, meshdata=None)[source]¶Set the mesh data
Parameters: | vertices : array-like | None
faces : array-like | None
vertex_colors : array-like | None
face_colors : array-like | None
color : instance of Color
vertex_values : array-like | None
meshdata : instance of MeshData | None
|
---|
shading
¶The shading method used.
shininess
¶The shininess
vispy.visuals.
PlaneVisual
(width=1, height=1, width_segments=1, height_segments=1, direction='+z', vertex_colors=None, face_colors=None, color=(0.5, 0.5, 1, 1), edge_color=None)[source]¶Bases: vispy.visuals.visual.CompoundVisual
Visual that displays a plane.
Parameters: | width : float
height : float
width_segments : int
height_segments : float
direction: unicode
vertex_colors : ndarray
face_colors : ndarray
color : Color
edge_color : tuple or Color
|
---|
vispy.visuals.
PolygonVisual
(pos=None, color='black', border_color=None, border_width=1, border_method='gl', triangulate=True, **kwargs)[source]¶Bases: vispy.visuals.visual.CompoundVisual
Displays a 2D polygon
Parameters: | pos : array
color : str | tuple | list of colors
border_color : str | tuple | list of colors
border_width : int
border_method : str
triangulate : boolean
**kwargs : dict
|
---|
border
¶The vispy.visuals.LineVisual that is owned by the PolygonVisual. It is used to draw the border of the polygon
border_color
¶The border color of the polygon.
color
¶The color of the polygon.
mesh
¶The vispy.visuals.MeshVisual that is owned by the PolygonVisual. It is used to fill in the polygon
pos
¶The vertex position of the polygon.
vispy.visuals.
RectangleVisual
(center=None, color='black', border_color=None, border_width=1, height=1.0, width=1.0, radius=[0.0, 0.0, 0.0, 0.0], **kwargs)[source]¶Bases: vispy.visuals.polygon.PolygonVisual
Displays a 2D rectangle with optional rounded corners
Parameters: | center : array
color : instance of Color
border_color : instance of Color
border_width : int
height : float
width : float
radius : float | array
**kwargs : dict
|
---|
center
¶The center of the ellipse
height
¶The height of the rectangle.
radius
¶The radius of curvature of rounded corners.
width
¶The width of the rectangle.
vispy.visuals.
RegularPolygonVisual
(center=None, color='black', border_color=None, border_width=1, radius=0.1, sides=4, **kwargs)[source]¶Bases: vispy.visuals.ellipse.EllipseVisual
Displays a regular polygon
Parameters: | center : array-like (x, y)
color : str | tuple | list of colors
border_color : str | tuple | list of colors
border_width: float
radius : float
sides : int
|
---|
sides
¶The number of sides in the regular polygon.
vispy.visuals.
ScrollingLinesVisual
(n_lines, line_size, dx, color=None, pos_offset=None, columns=None, cell_size=None)[source]¶Bases: vispy.visuals.visual.Visual
Displays many line strips of equal length, with the option to add new vertex data to one end of the lines.
Parameters: | n_lines : int
line_size : int
dx : float
color : array-like
pos_offset : array-like
columns : int
cell_size : tuple
|
---|
roll_data
(data)[source]¶Append new data to the right side of every line strip and remove as much data from the left.
Parameters: | data : array-like
|
---|
set_color
(color)[source]¶Set the array of colors for each line strip.
Parameters: | color : array-like
|
---|
vispy.visuals.
SpectrogramVisual
(x, n_fft=256, step=None, fs=1.0, window='hann', color_scale='log', cmap='cubehelix', clim='auto')[source]¶Bases: vispy.visuals.image.ImageVisual
Calculate and show a spectrogram
Parameters: | x : array-like
n_fft : int
step : int | None
fs : float
window : str | None
color_scale : {‘linear’, ‘log’}
cmap : str
clim : str | tuple
|
---|
freqs
¶The spectrogram frequencies
vispy.visuals.
SphereVisual
(radius=1.0, cols=30, rows=30, depth=30, subdivisions=3, method='latitude', vertex_colors=None, face_colors=None, color=(0.5, 0.5, 1, 1), edge_color=None, shading=None, **kwargs)[source]¶Bases: vispy.visuals.visual.CompoundVisual
Visual that displays a sphere
Parameters: | radius : float
cols : int
rows : int
depth : int
subdivisions : int
method : str
vertex_colors : ndarray
face_colors : ndarray
color : Color
edge_color : tuple or Color
shading : str | None
|
---|
border
¶The vispy.visuals.MeshVisual that used to draw the border.
mesh
¶The vispy.visuals.MeshVisual that used to fil in.
vispy.visuals.
SurfacePlotVisual
(x=None, y=None, z=None, colors=None, **kwargs)[source]¶Bases: vispy.visuals.mesh.MeshVisual
Displays a surface plot on a regular x,y grid
Parameters: | x : ndarray | None
y : ndarray | None
z : ndarray
colors : ndarray
|
---|
Notes
All arguments are optional.
Note that if vertex positions are updated, the normal vectors for each triangle must be recomputed. This is somewhat expensive if the surface was initialized with smooth=False and very expensive if smooth=True. For faster performance, initialize with compute_normals=False and use per-vertex colors or a material that does not require normals.
set_data
(x=None, y=None, z=None, colors=None)[source]¶Update the data in this surface plot.
Parameters: | x : ndarray | None
y : ndarray | None
z : ndarray
colors : ndarray
|
---|
vispy.visuals.
TextVisual
(text=None, color='black', bold=False, italic=False, face='OpenSans', font_size=12, pos=[0, 0, 0], rotation=0.0, anchor_x='center', anchor_y='center', method='cpu', font_manager=None)[source]¶Bases: vispy.visuals.visual.Visual
Visual that displays text
Parameters: | text : str | list of str
color : instance of Color
bold : bool
italic : bool
face : str
font_size : float
pos : tuple | list of tuple
rotation : float
anchor_x : str
anchor_y : str
method : str
font_manager : object | None
|
---|
color
¶The color of the text
font_size
¶The font size (in points) of the text
pos
¶The position of the text anchor in the local coordinate frame
rotation
¶The rotation of the text (clockwise, in degrees)
text
¶The text string
vispy.visuals.
TubeVisual
(points, radius=1.0, closed=False, color='purple', tube_points=8, shading='smooth', vertex_colors=None, face_colors=None, mode='triangles')[source]¶Bases: vispy.visuals.mesh.MeshVisual
Displays a tube around a piecewise-linear path.
The tube mesh is corrected following its Frenet curvature and torsion such that it varies smoothly along the curve, including if the tube is closed.
Parameters: | points : ndarray
radius : float | ndarray
closed : bool
color : Color | ColorArray
tube_points : int
shading : str | None
vertex_colors: ndarray | None
face_colors: ndarray | None
mode : str
|
---|
vispy.visuals.
Visual
(vcode='', fcode='', gcode=None, program=None, vshare=None)[source]¶Bases: vispy.visuals.visual.BaseVisual
Base class for all visuals that can be drawn using a single shader program.
This class creates a MultiProgram, which is an object that behaves like a normal shader program (you can assign shader code, upload values, set template variables, etc.) but internally manages multiple ModularProgram instances, one per view.
Subclasses generally only need to reimplement _compute_bounds, _prepare_draw, and _prepare_transforms.
Parameters: | vcode : str
fcode : str
gcode : str or None
program : instance of Program | None
vshare : instance of VisualShare | None
|
---|
attach
(filt, view=None)[source]¶Attach a Filter to this visual
Each filter modifies the appearance or behavior of the visual.
Parameters: | filt : object
view : instance of VisualView | None
|
---|
detach
(filt, view=None)[source]¶Detach a filter.
Parameters: | filt : object
view : instance of VisualView | None
|
---|
vispy.visuals.
VolumeVisual
(vol, clim=None, method='mip', threshold=None, relative_step_size=0.8, cmap='grays', emulate_texture=False)[source]¶Bases: vispy.visuals.visual.Visual
Displays a 3D Volume
Parameters: | vol : ndarray
clim : tuple of two floats | None
method : {‘mip’, ‘translucent’, ‘additive’, ‘iso’}
threshold : float
relative_step_size : float
cmap : str
emulate_texture : bool
|
---|
clim
¶The contrast limits that were applied to the volume data. Settable via set_data().
method
¶The render method to use
Current options are:
- translucent: voxel colors are blended along the view ray until the result is opaque.
- mip: maxiumum intensity projection. Cast a ray and display the maximum value that was encountered.
- additive: voxel colors are added along the view ray until the result is saturated.
- iso: isosurface. Cast a ray until a certain threshold is encountered. At that location, lighning calculations are performed to give the visual appearance of a surface.
relative_step_size
¶The relative step size used during raycasting.
Larger values yield higher performance at reduced quality. If set > 2.0 the ray skips entire voxels. Recommended values are between 0.5 and 1.5. The amount of quality degredation depends on the render method.
set_data
(vol, clim=None, copy=True)[source]¶Set the volume data.
Parameters: | vol : ndarray
clim : tuple | None
copy : bool | True
|
---|
threshold
¶The threshold value to apply for the isosurface render method.
vispy.visuals.
WindbarbVisual
(**kwargs)[source]¶Bases: vispy.visuals.visual.Visual
Visual displaying windbarbs.
set_data
(pos=None, wind=None, trig=True, size=50.0, antialias=1.0, edge_width=1.0, edge_color='black', face_color='white')[source]¶Set the data used to display this visual.
Parameters: | pos : array
wind : array
trig : bool
size : float or array
antialias : float
edge_width : float | None
edge_color : Color | ColorArray
face_color : Color | ColorArray
|
---|
vispy.visuals.filters.
Alpha
(alpha=1.0)[source]¶Bases: vispy.visuals.filters.base_filter.Filter
vispy.visuals.filters.
Clipper
(bounds=(0, 0, 1, 1), transform=None)[source]¶Bases: vispy.visuals.filters.base_filter.Filter
Clips visual output to a rectangular region.
bounds
¶The clipping boundaries.
This must be a tuple (x, y, w, h) in a clipping coordinate system that is defined by the transform property.
transform
¶The transform that maps from framebuffer coordinates to clipping coordinates.
vispy.visuals.filters.
ColorFilter
(filter=(1.0, 1.0, 1.0, 1.0))[source]¶Bases: vispy.visuals.filters.base_filter.Filter
vispy.visuals.filters.
IsolineFilter
(level=2.0, width=2.0, antialias=1.0, color='black')[source]¶Bases: vispy.visuals.filters.base_filter.Filter
vispy.visuals.filters.
PickingFilter
(id_=None)[source]¶Bases: vispy.visuals.filters.base_filter.Filter
Filter used to color visuals by a picking ID.
Note that the ID color uses the alpha channel, so this may not be used with blending enabled.
color
¶The RGBA color that will be drawn to the framebuffer for visuals that use this filter.
Provides classes representing different transform types suitable for use with visuals and scenes.
vispy.visuals.transforms.
NullTransform
[source]¶Bases: vispy.visuals.transforms.base_transform.BaseTransform
Transform having no effect on coordinates (identity transform).
vispy.visuals.transforms.
STTransform
(scale=None, translate=None)[source]¶Bases: vispy.visuals.transforms.base_transform.BaseTransform
Transform performing only scale and translate, in that order.
Parameters: | scale : array-like
translate : array-like
|
---|
from_mapping
(x0, x1)[source]¶Create an STTransform from the given mapping
See set_mapping for details.
Parameters: | x0 : array-like
x1 : array-like
|
---|---|
Returns: | t : instance of STTransform
|
imap
(coords)[source]¶Invert map coordinates
Parameters: | coords : array-like
|
---|---|
Returns: | coords : ndarray
|
map
(coords)[source]¶Map coordinates
Parameters: | coords : array-like
|
---|---|
Returns: | coords : ndarray
|
move
(move)[source]¶Change the translation of this transform by the amount given.
Parameters: | move : array-like
|
---|
set_mapping
(x0, x1, update=True)[source]¶Configure this transform such that it maps points x0 => x1
Parameters: | x0 : array-like, shape (2, 2) or (2, 3)
x1 : array-like, shape (2, 2) or (2, 3)
update : bool
|
---|
Examples
For example, if we wish to map the corners of a rectangle:
>>> p1 = [[0, 0], [200, 300]]
onto a unit cube:
>>> p2 = [[-1, -1], [1, 1]]
then we can generate the transform as follows:
>>> tr = STTransform()
>>> tr.set_mapping(p1, p2)
>>> assert tr.map(p1)[:,:2] == p2 # test
shader_map
()[source]¶Return a shader Function that accepts only a single vec4 argument and defines new attributes / uniforms supplying the Function with any static input.
zoom
(zoom, center=(0, 0, 0), mapped=True)[source]¶Update the transform such that its scale factor is changed, but the specified center point is left unchanged.
Parameters: | zoom : array-like
center : array-like
mapped : bool
|
---|
vispy.visuals.transforms.
MatrixTransform
(matrix=None)[source]¶Bases: vispy.visuals.transforms.base_transform.BaseTransform
Affine transformation class
Parameters: | matrix : array-like | None
|
---|
imap
(coords)[source]¶Inverse map coordinates
Parameters: | coords : array-like
|
---|---|
Returns: | coords : ndarray
|
map
(coords)[source]¶Map coordinates
Parameters: | coords : array-like
|
---|---|
Returns: | coords : ndarray
|
rotate
(angle, axis)[source]¶Rotate the matrix by some angle about a given axis.
The rotation is applied after the transformations already present in the matrix.
Parameters: | angle : float
axis : array-like
|
---|
scale
(scale, center=None)[source]¶Scale the matrix about a given origin.
The scaling is applied after the transformations already present in the matrix.
Parameters: | scale : array-like
center : array-like or None
|
---|
set_frustum
(l, r, b, t, n, f)[source]¶Set the frustum
Parameters: | l : float
r : float
b : float
t : float
n : float
f : float
|
---|
set_mapping
(points1, points2)[source]¶Set to a 3D transformation matrix that maps points1 onto points2.
Parameters: | points1 : array-like, shape (4, 3)
points2 : array-like, shape (4, 3)
|
---|
set_ortho
(l, r, b, t, n, f)[source]¶Set ortho transform
Parameters: | l : float
r : float
b : float
t : float
n : float
f : float
|
---|
set_perspective
(fov, aspect, near, far)[source]¶Set the perspective
Parameters: | fov : float
aspect : float
near : float
far : float
|
---|
vispy.visuals.transforms.
MatrixTransform
(matrix=None)[source]Bases: vispy.visuals.transforms.base_transform.BaseTransform
Affine transformation class
Parameters: | matrix : array-like | None
|
---|
imap
(coords)[source]Inverse map coordinates
Parameters: | coords : array-like
|
---|---|
Returns: | coords : ndarray
|
map
(coords)[source]Map coordinates
Parameters: | coords : array-like
|
---|---|
Returns: | coords : ndarray
|
rotate
(angle, axis)[source]Rotate the matrix by some angle about a given axis.
The rotation is applied after the transformations already present in the matrix.
Parameters: | angle : float
axis : array-like
|
---|
scale
(scale, center=None)[source]Scale the matrix about a given origin.
The scaling is applied after the transformations already present in the matrix.
Parameters: | scale : array-like
center : array-like or None
|
---|
set_frustum
(l, r, b, t, n, f)[source]Set the frustum
Parameters: | l : float
r : float
b : float
t : float
n : float
f : float
|
---|
set_mapping
(points1, points2)[source]Set to a 3D transformation matrix that maps points1 onto points2.
Parameters: | points1 : array-like, shape (4, 3)
points2 : array-like, shape (4, 3)
|
---|
set_ortho
(l, r, b, t, n, f)[source]Set ortho transform
Parameters: | l : float
r : float
b : float
t : float
n : float
f : float
|
---|
set_perspective
(fov, aspect, near, far)[source]Set the perspective
Parameters: | fov : float
aspect : float
near : float
far : float
|
---|
shader_imap
()[source]see shader_map.
shader_map
()[source]Return a shader Function that accepts only a single vec4 argument and defines new attributes / uniforms supplying the Function with any static input.
translate
(pos)[source]Translate the matrix
The translation is applied after the transformations already present in the matrix.
Parameters: | pos : arrayndarray
|
---|
vispy.visuals.transforms.
LogTransform
(base=None)[source]¶Bases: vispy.visuals.transforms.base_transform.BaseTransform
Transform perfoming logarithmic transformation on three axes.
Maps (x, y, z) => (log(base.x, x), log(base.y, y), log(base.z, z))
No transformation is applied for axes with base == 0.
If base < 0, then the inverse function is applied: x => base.x ** x
Parameters: | base : array-like
|
---|
base
¶base is a tuple (x, y, z) containing the log base that should be applied to each axis of the input vector. If any axis has a base <= 0, then that axis is not affected.
imap
(arg, *args, **kwargs)[source]¶Function
Parameters: | arg : array-like
*args : tuple
**kwargs : dict
|
---|---|
Returns: | value : object
|
vispy.visuals.transforms.
PolarTransform
[source]¶Bases: vispy.visuals.transforms.base_transform.BaseTransform
Polar transform
Maps (theta, r, z) to (x, y, z), where x = r*cos(theta) and y = r*sin(theta).
vispy.visuals.transforms.
ChainTransform
(*transforms)[source]¶Bases: vispy.visuals.transforms.base_transform.BaseTransform
BaseTransform subclass that performs a sequence of transformations in order. Internally, this class uses shaders.FunctionChain to generate its glsl_map and glsl_imap functions.
Arguments:
transforms
property.append
(tr)[source]¶Add a new transform to the end of this chain.
Parameters: | tr : instance of Transform
|
---|
imap
(coords)[source]¶Inverse map coordinates
Parameters: | coords : array-like
|
---|---|
Returns: | coords : ndarray
|
map
(coords)[source]¶Map coordinates
Parameters: | coords : array-like
|
---|---|
Returns: | coords : ndarray
|
prepend
(tr)[source]¶Add a new transform to the beginning of this chain.
Parameters: | tr : instance of Transform
|
---|
shader_map
()[source]¶Return a shader Function that accepts only a single vec4 argument and defines new attributes / uniforms supplying the Function with any static input.
simplified
¶A simplified representation of the same transformation.
transforms
¶The list of transform that make up the transform chain.
The order of transforms is given such that the last transform in the list is the first to be invoked when mapping coordinates through the chain.
For example, the following two mappings are equivalent:
# Map coordinates through individual transforms:
trans1 = STTransform(scale=(2, 3), translate=(0, 1))
trans2 = PolarTransform()
mapped = trans1.map(trans2.map(coords))
# Equivalent mapping through chain:
chain = ChainTransform([trans1, trans2])
mapped = chain.map(coords)
vispy.visuals.transforms.
TransformSystem
(canvas=None, dpi=None)[source]¶Bases: object
TransformSystem encapsulates information about the coordinate systems needed to draw a Visual.
Visual rendering operates in six coordinate systems:
Parameters: | canvas : Canvas
dpi : float
|
---|
Notes
By default, TransformSystems are configured such that the document coordinate system matches the logical pixels of the canvas,
Examples
1. To convert local vertex coordinates to normalized device coordinates in the vertex shader, we first need a vertex shader that supports configurable transformations:
vec4 a_position;
void main() {
gl_Position = $transform(a_position);
}
Next, we supply the complete chain of transforms when drawing the visual:
- def draw(tr_sys):
- tr = tr_sys.get_full_transform() self.program[‘transform’] = tr.shader_map() self.program[‘a_position’] = self.vertex_buffer self.program.draw(‘triangles’)
2. Draw a line whose width is given in mm. To start, we need normal vectors for each vertex, which tell us the direction the vertex should move in order to set the line width:
vec4 a_position;
vec4 a_normal;
float u_line_width;
float u_dpi;
void main() {
// map vertex position and normal vector to the document cs
vec4 doc_pos = $visual_to_doc(a_position);
vec4 doc_normal = $visual_to_doc(a_position + a_normal) - doc_pos;
// Use DPI to convert mm line width to logical pixels
float px_width = (u_line_width / 25.4) * dpi;
// expand by line width
doc_pos += normalize(doc_normal) * px_width;
// finally, map the remainder of the way to normalized device
// coordinates.
gl_Position = $doc_to_render(a_position);
}
In this case, we need to access
the transforms independently, so get_full_transform()
is not useful
here:
def draw(tr_sys):
# Send two parts of the full transform separately
self.program['visual_to_doc'] = tr_sys.visual_to_doc.shader_map()
doc_to_render = (tr_sys.framebuffer_transform *
tr_sys.document_transform)
self.program['visual_to_doc'] = doc_to_render.shader_map()
self.program['u_line_width'] = self.line_width
self.program['u_dpi'] = tr_sys.dpi
self.program['a_position'] = self.vertex_buffer
self.program['a_normal'] = self.normal_buffer
self.program.draw('triangles')
canvas
¶The Canvas being drawn to.
canvas_transform
¶Transform mapping from canvas coordinate frame to framebuffer coordinate frame.
configure
(viewport=None, fbo_size=None, fbo_rect=None, canvas=None)[source]¶Automatically configure the TransformSystem:
Parameters: | viewport : tuple or None
fbo_size : tuple or None
fbo_rect : tuple or None
canvas : Canvas instance
|
---|
document_transform
¶Transform mapping from document coordinate frame to the framebuffer (physical pixel) coordinate frame.
dpi
¶Physical resolution of the document coordinate system (dots per inch).
framebuffer_transform
¶Transform mapping from pixel coordinate frame to rendering coordinate frame.
get_transform
(map_from='visual', map_to='render')[source]¶Return a transform mapping between any two coordinate systems.
Parameters: | map_from : str
map_to : str
|
---|
scene_transform
¶Transform mapping from scene coordinate frame to document coordinate frame.
visual_transform
¶Transform mapping from visual local coordinate frame to scene coordinate frame.
vispy.visuals.transforms.
PanZoomTransform
(canvas=None, aspect=None, **kwargs)[source]¶Bases: vispy.visuals.transforms.linear.STTransform
Pan-zoom transform
Parameters: | canvas : instance of Canvas | None
aspect : float | None
**kwargs : dict
|
---|