The vispy.scene subpackage provides high-level, flexible, and easy to use functionality for creating scenes composed of multiple visual objects.
Scenegraphs are a commonly used system for describing a scene as a hierarchy of visual objects. Users need only create these visual objects and specify their location in the scene, and the scenegraph system will automatically draw the entire scene whenever an update is required.
Using the vispy scenegraph requires only a few steps:
For more information see:
Cameras are responsible for determining which part of a scene is displayed in a viewbox and for handling user input to change the view.
Several Camera subclasses are available to customize the projection of the scene such as 3D perspective and orthographic projections, 2D scale/translation, and other specialty cameras. A variety of user interaction styles are available for each camera including arcball, turntable, first-person, and pan/zoom interactions.
Internally, Cameras work by setting the transform of a SubScene object such that a certain part of the scene is mapped to the bounding rectangle of the ViewBox.
vispy.scene.cameras.
ArcballCamera
(fov=0.0, distance=None, translate_speed=1.0, **kwargs)[source]¶Bases: vispy.scene.cameras.perspective.Base3DRotationCamera
3D camera class that orbits around a center point while maintaining a view on a center point.
For this camera, the scale_factor
indicates the zoom level, and
the center
indicates the position to put at the center of the
view.
Parameters: | fov : float
distance : float | None
translate_speed : float
**kwargs : dict
|
---|
Notes
Interaction:
- LMB: orbits the view around its center point.
- RMB or scroll: change scale_factor (i.e. zoom level)
- SHIFT + LMB: translate the center point
- SHIFT + RMB: change FOV
vispy.scene.cameras.
BaseCamera
(interactive=True, flip=None, up='+z', parent=None, name=None)[source]¶Bases: vispy.scene.node.Node
Base camera class.
The Camera describes the perspective from which a ViewBox views its subscene, and the way that user interaction affects that perspective.
Most functionality is implemented in subclasses. This base class has no user interaction and causes the subscene to use the same coordinate system as the ViewBox.
Parameters: | interactive : bool
flip : tuple of bools
up : {‘+z’, ‘-z’, ‘+y’, ‘-y’, ‘+x’, ‘-x’}
parent : Node
name : str
|
---|
center
¶The center location for this camera
The exact meaning of this value differs per type of camera, but generally means the point of interest or the rotation point.
depth_value
¶The depth value to use in orthographic and perspective projection
For orthographic projections, depth_value
is the distance between
the near and far clipping planes. For perspective projections, it is
the ratio between the near and far clipping plane distances.
GL has a fixed amount of precision in the depth buffer, and a fixed constant will not work for both a very large range and very high precision. This property provides the user a way to override the default value if necessary.
fov
¶Field-of-view angle of the camera. If 0, the camera is in orthographic mode.
get_state
()[source]¶Get the current view state of the camera
Returns a dict of key-value pairs. The exact keys depend on the camera. Can be passed to set_state() (of this or another camera of the same type) to reproduce the state.
interactive
¶Boolean describing whether the camera should enable or disable user interaction.
link
(camera)[source]¶Link this camera with another camera of the same type
Linked camera’s keep each-others’ state in sync.
Parameters: | camera : instance of Camera
|
---|
on_canvas_change
(event)[source]¶Canvas change event handler
Parameters: | event : instance of Event
|
---|
pre_transform
¶A transform to apply to the beginning of the scene transform, in addition to anything else provided by this Camera.
set_default_state
()[source]¶Set the current state to be the default state to be applied when calling reset().
set_range
(x=None, y=None, z=None, margin=0.05)[source]¶Set the range of the view region for the camera
Parameters: | x : tuple | None
y : tuple | None
z : tuple | None
margin : float
|
---|
Notes
The view is set to the given range or to the scene boundaries if ranges are not specified. The ranges should be 2-element tuples specifying the min and max for each dimension.
For the PanZoomCamera the view is fully defined by the range. For e.g. the TurntableCamera the elevation and azimuth are not set. One should use reset() for that.
set_state
(state=None, **kwargs)[source]¶Set the view state of the camera
Should be a dict (or kwargs) as returned by get_state. It can be an incomlete dict, in which case only the specified properties are set.
Parameters: | state : dict
**kwargs : dict
|
---|
up
¶The dimension that is considered up.
view_changed
()[source]¶Called when this camera is changes its view. Also called when its associated with a viewbox.
viewbox
¶The viewbox that this camera applies to.
viewbox_key_event
(event)[source]¶ViewBox key event handler
Parameters: | event : instance of Event
|
---|
vispy.scene.cameras.
FlyCamera
(fov=60, rotation=None, **kwargs)[source]¶Bases: vispy.scene.cameras.perspective.PerspectiveCamera
The fly camera provides a way to explore 3D data using an interaction style that resembles a flight simulator.
For this camera, the scale_factor
indicates the speed of the
camera in units per second, and the center
indicates the
position of the camera.
Parameters: | fov : float
rotation : float | None
**kwargs : dict
|
---|
Notes
Interacting with this camera might need a bit of practice. The reaction to key presses can be customized by modifying the keymap property.
Moving:
- arrow keys, or WASD to move forward, backward, left and right
- F and C keys move up and down
- Space bar to brake
Viewing:
- Use the mouse while holding down LMB to control the pitch and yaw.
- Alternatively, the pitch and yaw can be changed using the keys IKJL
- The camera auto-rotates to make the bottom point down, manual rolling can be performed using Q and E.
auto_roll
¶Whether to rotate the camera automaticall to try and attempt to keep Z up.
keymap
¶A dictionary that maps keys to thruster directions
The keys in this dictionary are vispy key descriptions (from vispy.keys) or characters that represent keys. These are matched to the “key” attribute of key-press and key-release events.
The values are tuples, in which the first element specifies the magnitude of the acceleration, using negative values for “backward” thrust. A value of zero means to brake. The remaining elements specify the dimension to which the acceleration should be applied. These are 1, 2, 3 for forward/backward, left/right, up/down, and 4, 5, 6 for pitch, yaw, roll.
rotation
¶Get the full rotation. This rotation is composed of the normal rotation plus the extra rotation due to the current interaction of the user.
vispy.scene.cameras.
MagnifyCamera
(size_factor=0.25, radius_ratio=0.9, **kwargs)[source]¶Bases: vispy.scene.cameras.panzoom.PanZoomCamera
Camera implementing a MagnifyTransform combined with PanZoomCamera.
Parameters: | size_factor : float
radius_ratio : float
**kwargs : dict
|
---|
Notes
This Camera uses the mouse cursor position to set the center position of the MagnifyTransform, and uses mouse wheel events to adjust the magnification factor.
At high magnification, very small mouse movements can result in large changes, so we use a timer to animate transitions in the transform properties.
The camera also adjusts the size of its “lens” area when the view is resized.
on_timer
(event=None)[source]¶Timer event handler
Parameters: | event : instance of Event
|
---|
view_changed
()[source]¶Called when this camera is changes its view. Also called when its associated with a viewbox.
vispy.scene.cameras.
Magnify1DCamera
(size_factor=0.25, radius_ratio=0.9, **kwargs)[source]¶Bases: vispy.scene.cameras.magnify.MagnifyCamera
Camera implementing a MagnifyTransform combined with PanZoomCamera.
Parameters: | size_factor : float
radius_ratio : float
**kwargs : dict
|
---|
Notes
This Camera uses the mouse cursor position to set the center position of the MagnifyTransform, and uses mouse wheel events to adjust the magnification factor.
At high magnification, very small mouse movements can result in large changes, so we use a timer to animate transitions in the transform properties.
The camera also adjusts the size of its “lens” area when the view is resized.
vispy.scene.cameras.
PanZoomCamera
(rect=(0, 0, 1, 1), aspect=None, **kwargs)[source]¶Bases: vispy.scene.cameras.base_camera.BaseCamera
Camera implementing 2D pan/zoom mouse interaction.
For this camera, the scale_factor
indicates the zoom level, and
the center
indicates the center position of the view.
By default, this camera inverts the y axis of the scene. This usually results in the scene +y axis pointing upward because widgets (including ViewBox) have their +y axis pointing downward.
Parameters: | rect : Rect
aspect : float | None
**kwargs : dict
|
---|
Notes
Interaction:
- LMB: pan the view
- RMB or scroll: zooms the view
aspect
¶The ratio between the x and y dimension. E.g. to show a square image as square, the aspect should be 1. If None, the dimensions are scaled automatically, dependening on the available space. Otherwise the ratio between the dimensions is fixed.
center
¶The center location for this camera
The exact meaning of this value differs per type of camera, but generally means the point of interest or the rotation point.
pan
(*pan)[source]¶Pan the view.
Parameters: | *pan : length-2 sequence
|
---|
rect
¶The rectangular border of the ViewBox visible area, expressed in the coordinate system of the scene.
Note that the rectangle can have negative width or height, in
which case the corresponding dimension is flipped (this flipping
is independent from the camera’s flip
property).
viewbox_mouse_event
(event)[source]¶The SubScene received a mouse event; update transform accordingly.
Parameters: | event : instance of Event
|
---|
viewbox_resize_event
(event)[source]¶Modify the data aspect and scale factor, to adjust to the new window size.
Parameters: | event : instance of Event
|
---|
zoom
(factor, center=None)[source]¶Zoom in (or out) at the given center
Parameters: | factor : float or tuple
center : tuple of 2-4 elements
|
---|
vispy.scene.cameras.
TurntableCamera
(fov=0.0, elevation=30.0, azimuth=30.0, roll=0.0, distance=None, translate_speed=1.0, **kwargs)[source]¶Bases: vispy.scene.cameras.perspective.Base3DRotationCamera
3D camera class that orbits around a center point while maintaining a view on a center point.
For this camera, the scale_factor
indicates the zoom level, and
the center
indicates the position to put at the center of the
view.
Parameters: | fov : float
elevation : float
azimuth : float
roll : float
distance : float | None
translate_speed : float
**kwargs : dict
|
---|
Notes
Interaction:
- LMB: orbits the view around its center point.
- RMB or scroll: change scale_factor (i.e. zoom level)
- SHIFT + LMB: translate the center point
- SHIFT + RMB: change FOV
azimuth
¶The angle of the camera in degrees around the y axis. An angle of 0 places the camera within the (y, z) plane.
elevation
¶The angle of the camera in degrees above the horizontal (x, z) plane.
orbit
(azim, elev)[source]¶Orbits the camera around the center position.
Parameters: | azim : float
elev : float
|
---|
roll
¶The angle of the camera in degrees around the z axis. An angle of 0 places puts the camera upright.
vispy.scene.canvas.
SceneCanvas
(title='VisPy canvas', size=(800, 600), position=None, show=False, autoswap=True, app=None, create_native=True, vsync=False, resizable=True, decorate=True, fullscreen=False, config=None, shared=None, keys=None, parent=None, dpi=None, always_on_top=False, px_scale=1, bgcolor='black')[source]¶Bases: vispy.app.canvas.Canvas
, vispy.util.frozen.Frozen
A Canvas that automatically draws the contents of a scene
Parameters: | title : str
size : (width, height)
position : (x, y)
show : bool
autoswap : bool
app : Application | str
create_native : bool
vsync : bool
resizable : bool
decorate : bool
fullscreen : bool | int
config : dict
shared : Canvas | GLContext | None
keys : str | dict | None
parent : widget-object
dpi : float | None
always_on_top : bool
px_scale : int > 0
bgcolor : Color
|
---|
See also
Notes
Receives the following events:
- initialize
- resize
- draw
- mouse_press
- mouse_release
- mouse_double_click
- mouse_move
- mouse_wheel
- key_press
- key_release
- stylus
- touch
- close
The ordering of the mouse_double_click, mouse_press, and mouse_release events are not guaranteed to be consistent between backends. Only certain backends natively support double-clicking (currently Qt and WX); on other backends, they are detected manually with a fixed time delay. This can cause problems with accessibility, as increasing the OS detection time or using a dedicated double-click button will not be respected.
central_widget
¶Returns the default widget that occupies the entire area of the canvas.
draw_visual
(visual, event=None)[source]¶Draw a visual and its children to the canvas or currently active framebuffer.
Parameters: | visual : Visual
event : None or DrawEvent
|
---|
push_fbo
(fbo, offset, csize)[source]¶Push an FBO on the stack.
This activates the framebuffer and causes subsequent rendering to be written to the framebuffer rather than the canvas’s back buffer. This will also set the canvas viewport to cover the boundaries of the framebuffer.
Parameters: | fbo : instance of FrameBuffer
offset : tuple
csize : tuple
|
---|
push_viewport
(viewport)[source]¶Push a viewport (x, y, w, h) on the stack. Values must be integers relative to the active framebuffer.
Parameters: | viewport : tuple
|
---|
render
(region=None, size=None, bgcolor=None, crop=None)[source]¶Render the scene to an offscreen buffer and return the image array.
Parameters: | region : tuple | None
size : tuple | None
bgcolor : instance of Color | None
crop : array-like | None
|
---|---|
Returns: | image : array
|
scene
¶The SubScene object that represents the root node of the scene graph to be displayed.
vispy.scene.node.
Node
(parent=None, name=None, transforms=None)[source]¶Bases: object
Base class representing an object in a scene.
A group of nodes connected through parent-child relationships define a scenegraph. Nodes may have any number of children.
Each Node defines a transform
property, which describes the position,
orientation, scale, etc. of the Node relative to its parent. The Node’s
children inherit this property, and then further apply their own
transformations on top of that.
With the transform
property, each Node implicitly defines a “local”
coordinate system, and the Nodes and edges in the scenegraph can be thought
of as coordinate systems connected by transformation functions.
Parameters: | parent : Node
name : str
transforms : instance of TransformSystem | None
|
---|
canvas
¶The canvas in which this node’s scenegraph is being drawn.
children
¶A copy of the list of children of this node. Do not add
items to this list, but use x.parent = y
instead.
clip_children
¶Boolean indicating whether children of this node will inherit its clipper.
clipper
¶A visual filter that can be used to clip visuals to the boundaries of this node.
common_parent
(node)[source]¶Return the common parent of two entities
If the entities have no common parent, return None.
Parameters: | node : instance of Node
|
---|---|
Returns: | parent : instance of Node | None
|
describe_tree
(with_transform=False)[source]¶Create tree diagram of children
Parameters: | with_transform : bool
|
---|---|
Returns: | tree : str
|
document
¶The document is an optional property that is an node representing the coordinate system from which this node should make physical measurements such as px, mm, pt, in, etc. This coordinate system should be used when determining line widths, font sizes, and any other lengths specified in physical units.
The default is None; in this case, a default document is used during drawing (usually this is supplied by the SceneCanvas).
document_node
¶The node to be used as the document coordinate system.
By default, the document node is self.root_node.
is_child
(node)[source]¶Check if a node is a child of the current node
Parameters: | node : instance of Node
|
---|---|
Returns: | child : bool
|
node_path
(node)[source]¶Return two lists describing the path from this node to another
Parameters: | node : instance of Node
|
---|---|
Returns: | p1 : list
p2 : list
|
Notes
The first list starts with this node and ends with the common parent between the endpoint nodes. The second list contains the remainder of the path from the common parent to the specified ending node.
For example, consider the following scenegraph:
A --- B --- C --- D
--- E --- F
Calling D.node_path(F) will return:
([D, C, B], [E, F])
node_path_to_child
(node)[source]¶Return a list describing the path from this node to a child node
If node is not a (grand)child of this node, then raise RuntimeError.
Parameters: | node : instance of Node
|
---|---|
Returns: | path : list | None
|
node_path_transforms
(node)[source]¶Return the list of transforms along the path to another node.
The transforms are listed in reverse order, such that the last transform should be applied first when mapping from this node to the other.
Parameters: | node : instance of Node
|
---|---|
Returns: | transforms : list
|
node_transform
(node)[source]¶Return the transform that maps from the coordinate system of self to the local coordinate system of node.
Note that there must be a _single_ path in the scenegraph that connects the two entities; otherwise an exception will be raised.
Parameters: | node : instance of Node
|
---|---|
Returns: | transform : instance of ChainTransform
|
on_parent_change
(event)[source]¶Parent change event handler
Parameters: | event : instance of Event
|
---|
order
¶A value used to determine the order in which nodes are drawn.
Greater values are drawn later. Children are always drawn after their parent.
parent
¶The parent of this node in the scenegraph.
Nodes inherit coordinate transformations and some filters (opacity and clipping by default) from their parents. Setting this property assigns a new parent, changing the topology of the scenegraph.
May be set to None to remove this node (and its children) from a scenegraph.
parent_chain
()[source]¶Return the list of parents starting from this node. The chain ends at the first node with no parents.
picking
¶Boolean that determines whether this node (and its children) are drawn in picking mode.
scene_node
¶The first ancestor of this node that is a SubScene instance, or self if no such node exists.
set_transform
(type_, *args, **kwargs)[source]¶Create a new transform of type and assign it to this node.
All extra arguments are used in the construction of the transform.
Parameters: | type_ : str
*args : tuple
**kwargs : dict
|
---|
transform
¶The transform that maps the local coordinate frame to the coordinate frame of the parent.
update
()[source]¶Emit an event to inform listeners that properties of this Node have changed. Also request a canvas update.
visible
¶Whether this node should be drawn or not. Only applicable to nodes that can be drawn.
vispy.scene.events.
SceneMouseEvent
(event, visual)[source]¶Bases: vispy.util.event.Event
Represents a mouse event that occurred on a SceneCanvas. This event is delivered to all entities whose mouse interaction area is under the event.
The button pressed or released on this event.
A list of all buttons currently pressed on the mouse.
delta
¶The increment by which the mouse wheel has moved.
last_event
¶The mouse event immediately prior to this one. This property is None when no mouse buttons are pressed.
pos
¶The position of this event in the local coordinate system of the visual.
press_event
¶The mouse press event that initiated a mouse drag, if any.
The classes in scene.visuals are visuals that may be added to a scenegraph using the methods and properties defined in vispy.scene.Node such as name, visible, parent, children, etc…
These classes are automatically generated by mixing vispy.scene.Node with the Visual classes found in vispy.visuals.
For developing custom visuals, it is recommended to subclass from vispy.visuals.Visual rather than vispy.scene.Node.
vispy.scene.visuals.
VisualNode
(parent=None, name=None)[source]¶Bases: vispy.scene.node.Node
interactive
¶Whether this widget should be allowed to accept mouse and touch events.
picking
¶Boolean that determines whether this node (and its children) are drawn in picking mode.
vispy.scene.visuals.
Arrow
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.line.arrow.ArrowVisual
Arrow visual
This class inherits from visuals.ArrowVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
width:
connect : str or array
method : str
antialias : bool
arrows : array
arrow_type : string
arrow_size : float
arrow_color : Color, tuple, or array
|
---|
vispy.scene.visuals.
Axis
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.axis.AxisVisual
Axis visual
This class inherits from visuals.AxisVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
vispy.scene.visuals.
Box
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.box.BoxVisual
Visual that displays a box.
This class inherits from visuals.BoxVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
vispy.scene.visuals.
ColorBar
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.colorbar.ColorBarVisual
Visual subclass displaying a colorbar
This class inherits from visuals.ColorBarVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
vispy.scene.visuals.
Compound
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.visual.CompoundVisual
Visual consisting entirely of sub-visuals.
This class inherits from visuals.CompoundVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
vispy.scene.visuals.
Cube
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.cube.CubeVisual
Visual that displays a cube or cuboid
This class inherits from visuals.CubeVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | size : float or tuple
vertex_colors : ndarray
face_colors : ndarray
color : Color
edge_color : tuple or Color
parent : Node
name : string
|
---|
vispy.scene.visuals.
Ellipse
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.ellipse.EllipseVisual
Displays a 2D ellipse
This class inherits from visuals.EllipseVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
**kwargs : dict
|
---|
vispy.scene.visuals.
Graph
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.graphs.graph.GraphVisual
Visual for displaying graphs or networks.
This class inherits from visuals.GraphVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
See also
ArrowVisual
, MarkersVisual
vispy.scene.visuals.
GridLines
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.gridlines.GridLinesVisual
Displays regularly spaced grid lines in any coordinate system and at any scale.
This class inherits from visuals.GridLinesVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | scale : tuple
color : Color
parent : Node
name : string
|
---|
vispy.scene.visuals.
GridMesh
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.gridmesh.GridMeshVisual
Displays a mesh in a Cartesian grid about x,y,z coordinates.
This class inherits from visuals.GridMeshVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
**kwargs :
|
---|
vispy.scene.visuals.
Histogram
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.histogram.HistogramVisual
Visual that calculates and displays a histogram of data
This class inherits from visuals.HistogramVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | data : array-like
bins : int | array-like
color : instance of Color
orientation : {‘h’, ‘v’}
parent : Node
name : string
|
---|
vispy.scene.visuals.
Image
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.image.ImageVisual
Visual subclass displaying an image.
This class inherits from visuals.ImageVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | data : ndarray
method : str
grid: tuple (rows, cols)
cmap : str | ColorMap
clim : str | tuple
interpolation : str
parent : Node
name : string
**kwargs : dict
|
---|
Notes
The colormap functionality through cmap
and clim
are only used
if the data are 2D.
vispy.scene.visuals.
InfiniteLine
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.infinite_line.InfiniteLineVisual
Infinite horizontal or vertical line for 2D plots.
This class inherits from visuals.InfiniteLineVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | pos : float
color : list, tuple, or array
parent : Node
name : string
vertical:
|
---|
vispy.scene.visuals.
Isocurve
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.isocurve.IsocurveVisual
Displays an isocurve of a 2D scalar array.
This class inherits from visuals.IsocurveVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | data : ndarray | None
levels : ndarray, shape (Nlev,) | None
color_lev : Color, colormap name, tuple, list or array
clim : tuple
parent : Node
name : string
**kwargs : dict
|
---|
vispy.scene.visuals.
Isoline
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.isoline.IsolineVisual
Isocurves of a tri mesh with data at vertices at different levels.
This class inherits from visuals.IsolineVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
**kwargs : dict
|
---|
vispy.scene.visuals.
Isosurface
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.isosurface.IsosurfaceVisual
Displays an isosurface of a 3D scalar array.
This class inherits from visuals.IsosurfaceVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | data : ndarray | None
level: float | None
vertex_colors : ndarray | None
face_colors : ndarray | None
color : ndarray | None
parent : Node
name : string
**kwargs : dict
|
---|
vispy.scene.visuals.
Line
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.line.line.LineVisual
Line visual
This class inherits from visuals.LineVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | pos : array
color : Color, tuple, or array
parent : Node
name : string
width:
connect : str or array
method : str
antialias : bool
|
---|
vispy.scene.visuals.
LinearRegion
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.linear_region.LinearRegionVisual
Infinite horizontal or vertical region for 2D plots.
This class inherits from visuals.LinearRegionVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | pos : list, tuple or numpy array
color : list, tuple, or array
parent : Node
name : string
vertical:
|
---|
vispy.scene.visuals.
LinePlot
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.line_plot.LinePlotVisual
Visual displaying a plot line with optional markers.
This class inherits from visuals.LinePlotVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
**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.scene.visuals.
Markers
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.markers.MarkersVisual
Visual displaying marker symbols.
This class inherits from visuals.MarkersVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | parent : Node
name : string
|
---|
vispy.scene.visuals.
Mesh
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.mesh.MeshVisual
Mesh visual
This class inherits from visuals.MeshVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
**kwargs : dict
|
---|
vispy.scene.visuals.
Plane
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.plane.PlaneVisual
Visual that displays a plane.
This class inherits from visuals.PlaneVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
vispy.scene.visuals.
Polygon
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.polygon.PolygonVisual
Displays a 2D polygon
This class inherits from visuals.PolygonVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | pos : array
color : str | tuple | list of colors
border_color : str | tuple | list of colors
border_width : int
border_method : str
triangulate : boolean
parent : Node
name : string
**kwargs : dict
|
---|
vispy.scene.visuals.
Rectangle
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.rectangle.RectangleVisual
Displays a 2D rectangle with optional rounded corners
This class inherits from visuals.RectangleVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | center : array
color : instance of Color
border_color : instance of Color
border_width : int
height : float
width : float
radius : float | array
parent : Node
name : string
**kwargs : dict
|
---|
vispy.scene.visuals.
RegularPolygon
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.regular_polygon.RegularPolygonVisual
Displays a regular polygon
This class inherits from visuals.RegularPolygonVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
vispy.scene.visuals.
ScrollingLines
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.scrolling_lines.ScrollingLinesVisual
Displays many line strips of equal length, with the option to add new vertex data to one end of the lines.
This class inherits from visuals.ScrollingLinesVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | n_lines : int
line_size : int
dx : float
color : array-like
pos_offset : array-like
columns : int
cell_size : tuple
parent : Node
name : string
|
---|
vispy.scene.visuals.
Spectrogram
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.spectrogram.SpectrogramVisual
Calculate and show a spectrogram
This class inherits from visuals.SpectrogramVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | x : array-like
n_fft : int
step : int | None
fs : float
window : str | None
color_scale : {‘linear’, ‘log’}
cmap : str
clim : str | tuple
parent : Node
name : string
|
---|
vispy.scene.visuals.
Sphere
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.sphere.SphereVisual
Visual that displays a sphere
This class inherits from visuals.SphereVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
vispy.scene.visuals.
SurfacePlot
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.surface_plot.SurfacePlotVisual
Displays a surface plot on a regular x,y grid
This class inherits from visuals.SurfacePlotVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | x : ndarray | None
y : ndarray | None
z : ndarray
colors : ndarray
parent : Node
name : string
|
---|
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.
vispy.scene.visuals.
Text
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.text.text.TextVisual
Visual that displays text
This class inherits from visuals.TextVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
vispy.scene.visuals.
Tube
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.tube.TubeVisual
Displays a tube around a piecewise-linear path.
This class inherits from visuals.TubeVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
vispy.scene.visuals.
Volume
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.volume.VolumeVisual
Displays a 3D Volume
This class inherits from visuals.VolumeVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
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
parent : Node
name : string
|
---|
vispy.scene.visuals.
Windbarb
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.windbarb.WindbarbVisual
Visual displaying windbarbs.
This class inherits from visuals.WindbarbVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | parent : Node
name : string
|
---|
vispy.scene.visuals.
XYZAxis
(*args, **kwargs)[source]¶Bases: vispy.scene.visuals.VisualNode
, vispy.visuals.xyz_axis.XYZAxisVisual
Simple 3D axis for indicating coordinate system orientation. Axes are x=red, y=green, z=blue.
This class inherits from visuals.XYZAxisVisual and scene.Node, allowing the visual to be placed inside a scenegraph.
Parameters: | parent : Node
name : string
|
---|
The vispy.scene.widgets namespace provides a range of widgets to allow user interaction. Widgets are rectangular Visual objects such as buttons and sliders.
vispy.scene.widgets.
AxisWidget
(orientation='left', **kwargs)[source]¶Bases: vispy.scene.widgets.widget.Widget
Widget containing an axis
Parameters: | orientation : str
**kwargs : dict
|
---|
vispy.scene.widgets.
Console
(text_color='black', font_size=12.0, **kwargs)[source]¶Bases: vispy.scene.widgets.widget.Widget
Fast and failsafe text console
Parameters: | text_color : instance of Color
font_size : float
|
---|
font_size
¶The font size (in points) of the text
text_color
¶The color of the text
vispy.scene.widgets.
ColorBarWidget
(cmap, orientation, label='', label_color='black', clim=('', ''), border_width=0.0, border_color='black', padding=(0.2, 0.2), axis_ratio=0.05, **kwargs)[source]¶Bases: vispy.scene.widgets.widget.Widget
Widget containing a ColorBar
Parameters: | cmap : str | vispy.color.ColorMap
orientation : {‘left’, ‘right’, ‘top’, ‘bottom’}
label : str
label_color : str | vispy.color.Color
clim : tuple (min, max)
border_width : float (in px)
border_color : str | vispy.color.Color
padding : tuple (major_axis, minor_axis) [0, 1]
axis_ratio : float
|
---|
border_color
¶The color of the border around the ColorBar in pixels
border_width
¶The width of the border around the ColorBar in pixels
vispy.scene.widgets.
Grid
(spacing=6, **kwargs)[source]¶Bases: vispy.scene.widgets.widget.Widget
Widget that automatically sets the position and size of child Widgets to proportionally divide its internal area into a grid.
Parameters: | spacing : int
**kwargs : dict
|
---|
add_grid
(row=None, col=None, row_span=1, col_span=1, **kwargs)[source]¶Create a new Grid and add it as a child widget.
Parameters: | row : int
col : int
row_span : int
col_span : int
**kwargs : dict
|
---|
add_view
(row=None, col=None, row_span=1, col_span=1, **kwargs)[source]¶Create a new ViewBox and add it as a child widget.
Parameters: | row : int
col : int
row_span : int
col_span : int
**kwargs : dict
|
---|
add_widget
(widget=None, row=None, col=None, row_span=1, col_span=1, **kwargs)[source]¶Add a new widget to this grid. This will cause other widgets in the grid to be resized to make room for the new widget. Can be used to replace a widget as well
Parameters: | widget : Widget | None
row : int
col : int
row_span : int
col_span : int
**kwargs : dict
|
---|
Notes
The widget’s parent is automatically set to this grid, and all other parent(s) are removed.
vispy.scene.widgets.
Label
(text, rotation=0.0, **kwargs)[source]¶Bases: vispy.scene.widgets.widget.Widget
Label widget
Parameters: | text : str
rotation : float
**kwargs : dict
|
---|
vispy.scene.widgets.
ViewBox
(camera=None, **kwargs)[source]¶Bases: vispy.scene.widgets.widget.Widget
Provides a rectangular widget to which its subscene is rendered.
Three classes work together when using a ViewBox:
* The SubScene
class describes a “world” coordinate system and the
entities that live inside it.
* ViewBox is a “window” through which we view the
subscene. Multiple ViewBoxes may view the same subscene.
* Camera
describes both the perspective from which the
subscene is rendered, and the way user interaction affects that
perspective.
In general it is only necessary to create the ViewBox; a SubScene and Camera will be generated automatically.
Parameters: | camera : instance of Camera | str | None
**kwargs : dict
|
---|
add
(node)[source]¶Add an Node to the scene for this ViewBox.
This is a convenience method equivalent to node.parent = viewbox.scene
Parameters: | node : instance of Node
|
---|
camera
¶Get/set the Camera in use by this ViewBox
If a string is given (e.g. ‘panzoom’, ‘turntable’, ‘fly’). A corresponding camera is selected if it already exists in the scene, otherwise a new camera is created.
The camera object is made a child of the scene (if it is not already in the scene).
Multiple cameras can exist in one scene, although only one can be active at a time. A single camera can be used by multiple viewboxes at the same time.
get_scene_bounds
(dim=None)[source]¶Get the total bounds based on the visuals present in the scene
Parameters: | dim : int | None
|
---|---|
Returns: | bounds : list | tuple
|
is_in_scene
(node)[source]¶Get whether the given node is inside the scene of this viewbox.
Parameters: | node : instance of Node
|
---|
scene
¶The root node of the scene viewed by this ViewBox.
vispy.scene.widgets.
Widget
(pos=(0, 0), size=(10, 10), border_color=None, border_width=1, bgcolor=None, padding=0, margin=0, **kwargs)[source]¶Bases: vispy.scene.visuals.Compound
A widget takes up a rectangular space, intended for use in a 2D pixel coordinate frame.
The widget is positioned using the transform attribute (as any node), and its extent (size) is kept as a separate property.
Parameters: | pos : (x, y)
size : (w, h)
border_color : color
border_width : float
bgcolor : color
padding : int
margin : int
|
---|
add_grid
(*args, **kwargs)[source]¶Create a new Grid and add it as a child widget.
All arguments are given to Grid().
add_view
(*args, **kwargs)[source]¶Create a new ViewBox and add it as a child widget.
All arguments are given to ViewBox().
add_widget
(widget)[source]¶Add a Widget as a managed child of this Widget.
The child will be automatically positioned and sized to fill the entire space inside this Widget (unless _update_child_widgets is redefined).
Parameters: | widget : instance of Widget
|
---|---|
Returns: | widget : instance of Widget
|
bgcolor
¶The background color of the Widget.
border_color
¶The color of the border.
height
¶The actual height of the widget
height_max
¶The maximum height of the widget
height_min
¶The minimum height of the widget
inner_rect
¶The rectangular area inside the margin, border, and padding.
Generally widgets should avoid drawing or placing sub-widgets outside this rectangle.
picking
¶Boolean that determines whether this node (and its children) are drawn in picking mode.
remove_widget
(widget)[source]¶Remove a Widget as a managed child of this Widget.
Parameters: | widget : instance of Widget
|
---|
size
¶The size (w, h) of this widget.
If the widget is a child of another widget, then its size is assigned automatically by its parent.
stretch
¶Stretch factors (w, h) used when determining how much space to allocate to this widget in a layout.
If either stretch factor is None, then it will be assigned when the widget is added to a layout based on the number of columns or rows it occupies.
width
¶The actual width of this widget
width_max
¶The maximum width the widget can have
width_min
¶The minimum width the widget can have