-
Notifications
You must be signed in to change notification settings - Fork 25
cls_Axes
Inherits from Wibject.
An Axes instance represents the scene with a local coordinate system in which wobjects can be drawn. It has various properties to influence the appearance of the scene, such as aspect ratio and lighting.
To set the appearance of the axis (the thing that indicates x, y and z), use the properties of the Axis instance. For example: Axes.axis.showGrid = True
The cameraType determines how the data is visualized and how the user can interact with the data.
The daspect property represents the aspect ratio of the data as a three element tuple. The sign of the elements indicate dimensions being flipped. (The function imshow() for example flips the y-dimension). If daspectAuto is False, all dimensions are always equally zoomed (The function imshow() sets this to False).
An Axes can be created with the function vv.subplot() or vv.gca().
The Axes class implements the following properties:
axis, axisType, bgcolors, camera, cameraType, daspect, daspectAuto, daspectNormalized, legend, legendWibject, light0, lights, motionBlur, mousepos, useBuffer, wobjects
The Axes class implements the following methods:
Clear, Draw, GetLimits, GetView, MakeCurrent, SetLimits, SetView
Get the axis object associated with this axes. A new instance is created if it does not yet exist. This object can be used to change the appearance of the axis (tickmarks, labels, grid, etc.).
See also the [cls_BaseAxis Axis class].
Get/Set the axis type to use.
Currently supported are: * 'cartesian' - a normal axis (default) * 'polar' - a polar axis.
Get/Set the colors for the axes background gradient. If used, this value overrides the normal bgcolor property. Notes: * Set to None to disable the gradient * Setting two colors defines a gradient from top to bottom. * Setting four colors sets the colors at the four corners. * The value must be an iterable (2 or 4 elements) in which each element can be converted to a color.
Get/Set the current camera.
Setting can be done using: * The index of the camera; 1,2,3 for fly, 2d and 3d respectively. * A value as in the 'cameraType' property. * A new camera instance. This will replace any existing camera of the same type. To have multiple 3D cameras at the same axes, one needs to subclass cameras.ThreeDCamera.
Shared cameras
One can set the camera to the camera of another Axes, so that they share the same camera. A camera that is shared uses daspectAuto property of the first axes it was attached to.
Interactively changing a camera
By default, the camera can be changed using the keyboard using the shortcut ALT+i, where i is the camera number. Similarly the daspectAuto propert can be switched with ALT+d.
Get/Set the camera type to use.
Currently supported are: * '2d' or 2 - two dimensional camera that looks down the z-dimension. * '3d' or 3 - three dimensional camera. * 'fly' or 1 - a camera like a flight sim.
Get/set the data aspect ratio of the current camera. Setting will also update daspect for the other cameras.
The daspect is a 3-element tuple (x,y,z). If a 2-element tuple is given, z is assumed 1. Note that only the ratio between the values matters (i.e. (1,1,1) equals (2,2,2)). When a value is negative, the corresponding dimension is flipped.
Note that if daspectAuto is True, the camera automatically changes its daspect to nicely scale the data to fit the screen (but the sign is preserved).
Get/Set whether to scale the dimensions independently.
If True, the camera changes the value of its daspect to nicely fit the data on screen (but the sign is preserved). This can happen (depending on the type of camera) during resetting, zooming, and resizing of the axes.
If set to False, the daspect of all cameras is reverted to the user-set daspect.
Get the data aspect ratio, normalized such that the x scaling is +/- 1.
Get/Set the string labels for the legend. Upon setting, a legend wibject is automatically shown.
Get the legend wibject, so for exampe its position can be changed programatically.
Get the default light source in the scene.
Get a list of all available lights in the scene. Only light0 is enabeled by default.
Get/Set the amount of motion blur when interacting with this axes. The value should be a number between 0 and 1. Note: this is a rather useless feature :)
Get position of mouse in screen pixels, relative to this axes.
Get/Set whether to use a buffer; after drawing, a screenshot of the result is obtained and stored. When the axes needs to be redrawn, but has not changed, the buffer can be used to draw the contents at great speed (default True).
Get a shallow copy of the list of wobjects in the scene.
Clear the axes. Removing all wobjects in the scene.
Calls Draw(fast) on its figure, as the total opengl canvas has to be redrawn. This might change in the future though.
Get the limits of the axes as currently displayed. This can differ from what was set by SetLimits if the daspectAuto is False. With a 2D camera, this returns the limits for x and y determined by the view. With a 3D camera, this returns the x, y, and z extents of the coordinate axes.
Get a dictionary with the camera parameters. The parameters are named so they can be changed in a natural way and fed back using SetView(). Note that the parameters can differ for different camera types.
Make this the current axes. Also makes the containing figure the current figure.
Set the limits of the scene. For the 2D camera, these are taken as hints to set the camera view. For the 3D camear, they determine where the axis is drawn.
Returns a 3-element tuple of visvis.Range objects.
Parameters
rangeX : (min, max), optional
The range for the x dimension.
rangeY : (min, max), optional
The range for the y dimension.
rangeZ : (min, max), optional
The range for the z dimension.
margin : scalar
Represents the fraction of the range to add for the ranges that are automatically obtained (default 2%).
Notes
Each range can be None, a 2 element iterable, or a visvis.Range object. If a range is None, the range is automatically obtained from the wobjects currently in the scene. To set the range that will fit all wobjects, simply use "SetLimits()"
Set the camera view using the given dictionary with camera parameters. Camera parameters can also be passed as keyword/value pairs; these will supersede the values of the same key in s. If neither s nor any keywords are set, the camera is reset to its initial state.