functions - almarklein/visvis GitHub Wiki

The functions of Visvis

(Visvis version 1.9.4)

Visvis is object oriented by nature, but provides a convenient interface in the form of the following functions, inspired by the plotting interface of Matlab and Matplotlib.

Certain functions that you might be used to from Matlab or Matplotlib are not listed here; they are availabe as properties of the wibjects and wobjects (mostly the Axes and Axis objects). As a rule of thumb, a function is available if it creates something (as with xlabel, title, or colorbar) and not if it changes a property (such as showGrid or xTicks). Further, there are also functions that do something that cannot be done in an object oriented way (such as getframe() or imwrite()).

List of all available functions:

aVolume
axis
bar
bar3
boxplot
callLater
cla
clf
close
closeAll
colorbar
draw
figure
gca
gcf
getOpenGlInfo
getframe
ginput
grid
help
hist
imread
imshow
imwrite
isocontour
isosurface
kde
legend
mesh
meshRead
meshWrite
movieRead
movieShow
movieWrite
peaks
plot
polarplot
processEvents
record
reportIssue
screenshot
solidBox
solidCone
solidCylinder
solidLine
solidRing
solidSphere
solidTeapot
subplot
surf
title
use
view
volread
volshow
volshow2
volshow3
xlabel
ylabel
zlabel

Creates a volume (3D image) with random bars. The returned numpy array has values between 0 and 1. Intended for quick illustration and test purposes.

Parameters

N : int
The number of bars for each dimension.
size : int
The size of the volume (for each dimension).

Convenience function to set axis properties. Note that all functionality can also be applied via the properties of the Axis object.

Parameters

command : string
The setting command to apply. See below.
axes : Axes instance
The axes to apply the setting to. Uses the current axes by default.

Possible string commands
* off: hide the axis (Axes.axis.visible = False) * on: show the axis (Axes.axis.visible = True) * equal: make a circle be displayed circular (Axes.daspectAuto = False) * auto: change the range for each dimension indepdently (Axes.daspectAuto = True) * tight: show all data (Axes.SetLimits()) * ij: flip the y-axis (make second element of Axes.daspect negative) * xy: (make all elements of Axes.daspect positive) If you want to set an Axes' limits, use Axes.SetLimits(xlim, ylim, zlim).

Create a bar chart and returns a Bars2D instance that can be used to change the appearance of the bars (such as color).

Usage
* bar(H, ...) creates bars of specified height. * bar(X, H, ...) also supply their x-coordinates

Keyword arguments

width : scalar
The width of the bars.
color : {3-element tuple, color-char}
The color of the bars
colors : {3-element tuple, color-char}
A color value for each bar.
lc : {3-element tuple, color-char}
The color for the bar lines (i.e. edges).
lw : scalar
The width of the bar lines (i.e. edges).
axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Create a 3D bar chart and returns a Bars3D instance that can be used to change the appearance of the bars (such as lighting properties and color).

Usage
* bar3(H, ...) creates bars of specified height. * bar3(X, H, ...) also supply their x-coordinates * bar3(X, Y, H, ...) supply both x- and y-coordinates

Keyword arguments

width : scalar
The width of the bars.
axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Create a box and whisker plot and returns a BoxPlot wobject that can be used to change the appearance of the boxes (such as color).

If whiskers=='violin' creates a violin plot, which displays the kernel density estimate (kde) of each data.

Usage
* boxplot(data, ...) creates boxplots for the given list of data * boxplot(X, data, ...) also supply x-coordinates for each data

Arguments

X : iterable (optional)
Specify x position of the boxes.
data : list
List of data, where each data is a sequence (something that can be passed to numpy.array()).
width : scalar
The width of the boxes.
whiskers : scalar or string
How to draw the whiskers. If a scalar is given, it defines the length of the whiskers as a function of the IQR. In this case any points lying beyond the whiskers are drawn as outliers. If 'minmax', the whiskers simply extend to the maximal data range. If 'std', the whiskers indicate the mean +/- the standard deviation. If 'violin', a violin plot is drawn, which shows the probability density function completely.
axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Call a callable after a specified delay (in seconds), with the specified arguments and keyword-arguments.

Parameters

delay : scalar
The delay in seconds. If zero, the callable is called right after the current processing has returned to the main loop, before any other visvis events are processed.
callable : a callable object
The callback that is called when the delay has passed.

See also vv.Event

Clear the current axes.

Clear current figure.

Close a figure.

fig can be a Figure object or an integer representing the id of the figure to close. Note that for the first case, you migh also call fig.Destroy().

Closes all figures.

Attach a colorbar to the given axes (or the current axes if not given). The reference to the colorbar instance is returned. Also see the vv.ColormapEditor wibject.

Makes the given figure (or the current figure if None) draw itself. If fast is True, some wobjects can draw itself faster at reduced quality.

This function is now more or less deprecated; visvis is designed to invoke a draw whenever necessary.

Set the specified figure to be the current figure, creating it if necessary. fig may be a Figure object, a figure number (a positive integer), or None. Returns the specified or created figure.

Get the current axes in the current figure. If there is no axes, an Axes instance is created. To make an axes current, use Axes.MakeCurrent().

See also gcf(), Figure.MakeCurrent(), Figure.currentAxes

Get the current figure. If there is no figure yet, figure() is called to create one. To make a figure current, use Figure.MakeCurrent().

See also gca()

Get information about the OpenGl version on this system. Returned is a tuple (version, vendor, renderer, extensions)

A figure is created and removed to create an openGl context if this is necessary.

Get a snapshot of the current figure or axes or axesContainer. It is retured as a numpy array (color image). Also see vv.screenshot().

Graphical input: select N number of points with the mouse. Returns a 2D pointset.

Parameters

N : int
The maximum number of points to capture. If N=0, will keep capturing until the user stops it. The capturing always stops when enter is pressed or the mouse is double clicked. In the latter case a final point is added.
axes : Axes instance
The axes to capture the points in, or the current axes if not given.
ms : markerStyle
The marker style to use for the points. See plot.

Any other keyword arguments are passed to plot to show the selected points and the lines between them.

Create a wireframe parametric surface.

Usage
* grid(Z) - create a grid mesh using the given image with z coordinates. * grid(Z, C) - also supply a texture image to map. * grid(X, Y, Z) - give x, y and z coordinates. * grid(X, Y, Z, C) - also supply a texture image to map.

Parameters

Z : A MxN 2D array

X : A length N 1D array, or a MxN 2D array

Y : A length M 1D array, or a MxN 2D array

C : A MxN 2D array, or a AxBx3 3D array
If 2D, C specifies a colormap index for each vertex of Z. If 3D, C gives a RGB image to be mapped over Z. In this case, the sizes of C and Z need not match.

Keyword arguments

axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Notes
* This function should not be confused with the axis grid, see the Axis.showGrid property. * This function is know in Matlab as mesh(), but to avoid confusion with the vv.Mesh class, it is called grid() in visvis.

Also see surf() and the solid*() methods.

Open a webbrowser with the API documentation of visvis.

Note that all visvis classes and functions have docstrings, so typing for example "vv.Mesh?" in IPython or IEP gives you documentation on the fly.

Make a histogram plot of the data. Uses np.histogram (new version) internally. See its docs for more information.

See the kde() function for a more accurate density estimate. See the vv.StatData for more statistics on data.

Parameters

a : array_like
The data to calculate the historgam of.
bins : int or sequence of scalars, optional
If bins is an int, it defines the number of equal-width bins in the given range. If bins is a sequence, it defines the bin edges, including the rightmost edge, allowing for non-uniform bin widths. If bins is not given, the best number of bins is determined automatically using the Freedman-Diaconis rule.
range : (float, float)
The lower and upper range of the bins. If not provided, range is simply (a.min(), a.max()). Values outside the range are ignored.
normed : bool
If False, the result will contain the number of samples in each bin. If True, the result is the value of the probability density function at the bin, normalized such that the integral over the range is 1. Note that the sum of the histogram values will not be equal to 1 unless bins of unity width are chosen; it is not a probability mass function.
weights : array_like
An array of weights, of the same shape as a. Each value in a only contributes its associated weight towards the bin count (instead of 1). If normed is True, the weights are normalized, so that the integral of the density over the range remains 1.

Read image from file or http, requires imageio.

Display a 2D image and returns the Texture2D object.

If the image is an anisotropic array (vv.Aaray), the appropriate scale and translate transformations are applied.

Parameters

im : numpy array
The image to visualize. Can be grayscale, RGB, or RGBA.
clim : 2-element tuple
The color limits to scale the intensities of the image. If not given, the im.min() and im.max() are used (neglecting nan and inf).
aa : 0, 1, 2 or 3
Anti aliasing. 0 means no anti-aliasing. The highee the number, the better quality the anti-aliasing is (Requires a GLSL compatible OpenGl implementation). Default 2.
interpolation : bool
Use no interpolation (i.e. nearest neighbour) or linear interpolation.
cm : Colormap
Set the colormap to apply in case the image is grayscale.
axesAdjust : bool
If axesAdjust==True, this function will call axes.SetLimits(), set the camera type to 2D, and make axes.daspect[1] negative (i.e. flip the y-axis). If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Notes

New images are positioned on z=-0.1, such that lines and points are visible over the image. This z-pos of textures already in the axes are moved backwards if new images are displayed with imshow, such that the new image is displayed over the older ones. (the changed value is Texture2D._trafo_trans.dz)

Visvis does not use the "hold on / hold off" system. So if updating an image, better use Texture2D.Refresh() or call Axes.Clear() first.

Write image (numpy array) to file, requires imageio.

Parameters

filename : string
The name of the file to store the screenshot to. If filename is None, the interpolated image is returned as a numpy array.
image : numpy array
The image to write.
format : string
The format for the image to be saved in. If not given, the format is deduced from the filename.

Notes
* For floating point images, 0 is considered black and 1 is white. * For integer types, 0 is considered black and 255 is white.

Uses scikit-image to calculate the iso contours for the given 2D image. If isovalue is not given or None, a value between the min and max of the image is used.

Returns a pointset in which each two subsequent points form a line piece. This van be best visualized using "vv.plot(result, ls='+')".

Uses scikit-image to calculate the isosurface for the given 3D image. Returns a vv.BaseMesh object.

Parameters

vol : 3D numpy array
The volume for which to calculate the isosurface.
isovalue : float
The value at which the surface should be created. If not given or None, the average of the min and max of vol is used.
step : int
The stepsize for stepping through the volume. Larger steps yield faster but coarser results. The result shall always be topologically correct though.
useClassic : bool
If True, uses the classic marching cubes by Lorensen (1987) is used. This algorithm has many ambiguities and is not guaranteed to produce a topologically correct result.
useValues : bool
If True, the returned BaseMesh object will also have a value for each vertex, which is related to the maximum value in a local region near the isosurface.

Make a kernerl density estimate plot of the data. This is like a histogram, but produces a smoother result, thereby better represening the probability density function.

See the vv.StatData for more statistics on data.

Parameters

a : array_like
The data to calculate the historgam of.
bins : int (optional)
The number of bins. If not given, the best number of bins is determined automatically using the Freedman-Diaconis rule.
kernel : float or sequence (optional)
The kernel to use for distributing the values. If a scalar is given, a Gaussian kernel with a sigma equal to the given number is used. If not given, the best kernel is chosen baded on the number of bins.
kwargs : keyword arguments
These are given to the plot function.

Can also be called with a single argument being a tuple/list of strings.

Set the string labels for the legend. If no string labels are given, the legend wibject is hidden again.

See also the Axes.legend property.

Display a mesh of polygons, either triangles or quads.

Parameters

vertices : Nx3 array
The positions of the vertices in 3D space.
faces : array or list of indices
The faces given in terms of the vertex indices. Should be 1D, in which case the indices are grouped into groups of verticesPerFace, or Mx3 or Mx4, in which case verticesPerFace is ignored. The front of the face is defined using the right-hand-rule.
normals : Nx3
A list of vectors specifying the vertex normals.
values : N, Nx2, Nx3, or Nx4 array
Sets the color of each vertex, using values from a colormap (1D), colors from a texture (Nx2), RGB values (Nx3), or RGBA value (Nx4).
verticesPerFace : 3 or 4
Whether the faces are triangle or quads, if not specified in faces.
colormap : a Colormap
If values is 1D, the vertex colors are set from this colormap.
clim : 2 element array
If values is 1D, sets the values to be mapped to the limits of the colormap. If None, the min and max of values are used.
texture : a Texture
If values is Nx2, the vertex colors are set from this texture.
axesAdjust : bool
Whether to adjust the view after the mesh is drawn.
axes : Axes instance
The axes into which the mesh will be added. If None, the current axes will be used.

Parameters

fname : string
The name of the file to read.
check : bool
For the STL format: if check is True and the file is in ascii, some checks to the integrity of the file are done (which is a bit slower).

Notes on formats
* The STL format (.stl) is rather limited in the definition of the faces; smooth shading is not possible on an STL mesh. * The Wavefront format (.obj) is widely available. * For the wavefront format, material, nurbs and other fancy stuff is ignored. * The SSDF format (.ssdf or .bsdf) is the most efficient in terms of memory and speed, but is not widely available.

Parameters

fname : string
The filename to write to. The extension should be one of the following: .obj .stl .ssdf .bsdf
mesh : vv.BaseMesh
The mesh instance to write.
name : string (optional)
The name of the object (e.g. 'teapot')
bin : bool
For the STL format: whether to write binary, which is much more compact then ascii.

Notes on formats
* The STL format (.stl) is rather limited in the definition of the faces; smooth shading is not possible on an STL mesh. * The Wavefront format (.obj) is widely available. * The SSDF format (.ssdf or .bsdf) is the most efficient in terms of memory and speed, but is not widely available.

Proxy for imageio.mimread()

Show the images in the given list as a movie.

Parameters

images : list
The 2D images (can be color images) that the movie consists of.
clim : (min, max)
The color limits to apply. See imshow.
duration : scalar
The duration (in seconds) of each frame. The real duration can differ from the given duration, depending on the performance of your system.
axesAdjust : bool
If axesAdjust==True, this function will call axes.SetLimits(), set the camera type to 2D, and make axes.daspect[1] negative (i.e. flip the y-axis). If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Proxy for imageio.mimwrite()

Returs a 2D map of z-values that represent an example landscape with Gaussian blobs.

Plot 1, 2 or 3 dimensional data and return the Line object.

Usage
* plot(Y, ...) plots a 1D signal, with the values plotted along the y-axis * plot(X, Y, ...) also supplies x coordinates * plot(X, Y, Z, ...) also supplies z coordinates * plot(P, ...) plots using a Point or Pointset instance

Keyword arguments

(The longer names for the line properties can also be used)
lw : scalar
lineWidth. The width of the line. If zero, no line is drawn.
mw : scalar
markerWidth. The width of the marker. If zero, no marker is drawn.
mew : scalar
markerEdgeWidth. The width of the edge of the marker.
lc : 3-element tuple or char
lineColor. The color of the line. A tuple should represent the RGB values between 0 and 1. If a char is given it must be one of 'rgbmcywk', for reg, green, blue, magenta, cyan, yellow, white, black, respectively.
mc : 3-element tuple or char
markerColor. The color of the marker. See lineColor.
mec : 3-element tuple or char
markerEdgeColor. The color of the edge of the marker.
ls : string
lineStyle. The style of the line. (See below)
ms : string
markerStyle. The style of the marker. (See below)
axesAdjust : bool
If axesAdjust==True, this function will call axes.SetLimits(), set the camera type to 2D when plotting 2D data and to 3D when plotting 3D data. If daspectAuto has not been set yet, it is set to True.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Line styles
* Solid line: '-' * Dotted line: ':' * Dashed line: '--' * Dash-dot line: '-.' or '.-' * A line that is drawn between each pair of points: '+' * No line: '' or None.

Marker styles
* Plus: '+' * Cross: 'x' * Square: 's' * Diamond: 'd' * Triangle (pointing up, down, left, right): '^', 'v', '<', '>' * Pentagram star: 'p' or '*' * Hexgram: 'h' * Point/cirle: 'o' or '.' * No marker: '' or None

Plot 2D polar data, using a polar axis to draw a polar grid.

Usage
* plot(Y, ...) plots a 1D polar signal. * plot(X, Y, ...) also supplies angular coordinates * plot(P, ...) plots using a Point or Pointset instance

Keyword arguments

(The longer names for the line properties can also be used)
lw : scalar
lineWidth. The width of the line. If zero, no line is drawn.
mw : scalar
markerWidth. The width of the marker. If zero, no marker is drawn.
mew : scalar
markerEdgeWidth. The width of the edge of the marker.
lc : 3-element tuple or char
lineColor. The color of the line. A tuple should represent the RGB values between 0 and 1. If a char is given it must be one of 'rgbmcywk', for reg, green, blue, magenta, cyan, yellow, white, black, respectively.
mc : 3-element tuple or char
markerColor. The color of the marker. See lineColor.
mec : 3-element tuple or char
markerEdgeColor. The color of the edge of the marker.
ls : string
lineStyle. The style of the line. (See below)
ms : string
markerStyle. The style of the marker. (See below)
axesAdjust : bool
If axesAdjust==True, this function will call axes.SetLimits(), and set the camera type to 2D.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Line styles
* Solid line: '-' * Dotted line: ':' * Dashed line: '--' * Dash-dot line: '-.' or '.-' * A line that is drawn between each pair of points: '+' * No line: '' or None.

Marker styles
* Plus: '+' * Cross: 'x' * Square: 's' * Diamond: 'd' * Triangle (pointing up, down, left, right): '^', 'v', '<', '>' * Pentagram star: 'p' or '*' * Hexgram: 'h' * Point/cirle: 'o' or '.' * No marker: '' or None

Polar axis

This polar axis has a few specialized methods for adjusting the polar plot. Access these via vv.gca().axis. * SetLimits(thetaRange, radialRange) * thetaRange, radialRange = GetLimits() * angularRefPos: Get and Set methods for the relative screen angle of the 0 degree polar reference. Default is 0 degs which corresponds to the positive x-axis (y =0) * isCW: Get and Set methods for the sense of rotation CCW or CW. This method takes/returns a bool (True if the default CW).

Interaction
* Drag mouse up/down to translate radial axis. * Drag mouse left/right to rotate angular ref position. * Drag mouse + shift key up/down to rescale radial axis (min R fixed).

Processes all GUI events (and thereby all visvis events). Users can periodically call this function during running an algorithm to keep the figures responsove.

Note that IEP and IPython can integrate the GUI event loop to periodically update the GUI events when idle.

Also see Figure.DrawNow()

Take a snapshot of the given figure or axes after each draw. A Recorder instance is returned, with which the recording can be stopped, continued, and exported to GIF, SWF or AVI.

help()

Open a webbrowser with the visvis website at the issue list.

Make a screenshot and store it to a file, using cubic interpolation to increase the resolution (and quality) of the image.

Parameters

filename : string
The name of the file to store the screenshot to. If filename is None, the interpolated image is returned as a numpy array.
ob : Axes, AxesContainer, or Figure
The object to take the screenshot of. The AxesContainer can be obtained using vv.gca().parent. It can be usefull to take a screeshot of an axes including thickmarks and labels.
sf : integer
The scale factor. The image is increased in size with this factor, using a high quality interpolation method. A factor of 2 or 3 is recommended; the image quality does not improve with higher factors. If using a sf larger than 1, the image is best saved in the jpg format.
bg : 3-element tuple or char
The color of the background. If bg is given, ob.bgcolor is set to bg before the frame is captured.
format : string
The format for the screenshot to be saved in. If not given, the format is deduced from the filename.

Notes

Uses vv.getframe(ob) to obtain the image in the figure or axes. That image is interpolated with the given scale factor (sf) using bicubic interpolation. Then vv.imwrite(filename, ..) is used to store the resulting image to a file.

Rationale

We'd prefer storing screenshots of plots as vector (eps) images, but the nature of OpenGl prevents this. By applying high quality interpolation (using a cardinal spline), the resolution can be increased, thereby significantly improving the visibility/smoothness for lines and fonts. Use this to produce publication quality snapshots of your plots.

Creates a solid cube (or box if you scale it) centered at the origin. Returns an OrientableMesh.

Parameters

Note that translation, scaling, and direction can also be given using a Point instance.
translation : (dx, dy, dz), optional
The translation in world units of the created world object. scaling: (sx, sy, sz), optional The scaling in world units of the created world object. direction: (nx, ny, nz), optional Normal vector that indicates the direction of the created world object. rotation: scalar, optional The anle (in degrees) to rotate the created world object around its direction vector.
axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Creates a solid cone with quad faces and its base at the origin. Returns an OrientableMesh instance.

Parameters

Note that translation, scaling, and direction can also be given using a Point instance.
translation : (dx, dy, dz), optional
The translation in world units of the created world object. scaling: (sx, sy, sz), optional The scaling in world units of the created world object. direction: (nx, ny, nz), optional Normal vector that indicates the direction of the created world object. rotation: scalar, optional The anle (in degrees) to rotate the created world object around its direction vector.
N : int
The number of subdivisions around its axis. If smaller than 8, flat shading is used instead of smooth shading. With N=4, a pyramid is obtained.
M : int
The number of subdivisions along its axis. If smaller than 8, flat shading is used instead of smooth shading.
axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Creates a cylinder object with quad faces and its base at the origin. Returns an OrientableMesh instance.

Parameters

Note that translation, scaling, and direction can also be given using a Point instance.
translation : (dx, dy, dz), optional
The translation in world units of the created world object. scaling: (sx, sy, sz), optional The scaling in world units of the created world object. direction: (nx, ny, nz), optional Normal vector that indicates the direction of the created world object. rotation: scalar, optional The anle (in degrees) to rotate the created world object around its direction vector.
N : int
The number of subdivisions around its axis. If smaller than 8, flat shading is used instead of smooth shading.
M : int
The number of subdivisions along its axis. If smaller than 8, flat shading is used instead of smooth shading.
axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Creates a solid line in 3D space.

Parameters

Note that translation, scaling, and direction can also be given using a Point instance.
pp : Pointset
The sequence of points of which the line consists.
radius : scalar or sequence
The radius of the line to create. If a sequence if given, it specifies the radius for each point in pp.
N : int
The number of subdivisions around its centerline. If smaller than 8, flat shading is used instead of smooth shading.
axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Creates a solid ring with quad faces oriented at the origin. Returns an OrientableMesh instance.

Parameters

Note that translation, scaling, and direction can also be given using a Point instance.
translation : (dx, dy, dz), optional
The translation in world units of the created world object. scaling: (sx, sy, sz), optional The scaling in world units of the created world object. direction: (nx, ny, nz), optional Normal vector that indicates the direction of the created world object. rotation: scalar, optional The anle (in degrees) to rotate the created world object around its direction vector.
thickness : scalar
The tickness of the ring, represented as a fraction of the radius.
N : int
The number of subdivisions around its axis. If smaller than 8, flat shading is used instead of smooth shading.
M : int
The number of subdivisions along its axis. If smaller than 8, flat shading is used instead of smooth shading.
axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Creates a solid sphere with quad faces and centered at the origin. Returns an OrientableMesh instance.

Parameters

Note that translation, scaling, and direction can also be given using a Point instance.
translation : (dx, dy, dz), optional
The translation in world units of the created world object. scaling: (sx, sy, sz), optional The scaling in world units of the created world object. direction: (nx, ny, nz), optional Normal vector that indicates the direction of the created world object. rotation: scalar, optional The anle (in degrees) to rotate the created world object around its direction vector.
N : int
The number of subdivisions around the Z axis (similar to lines of longitude). If smaller than 8, flat shading is used instead of smooth shading.
M : int
The number of subdivisions along the Z axis (similar to lines of latitude). If smaller than 8, flat shading is used instead of smooth shading.
axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Create a model of a teapot (a teapotahedron) with its bottom at the origin. Returns an OrientableMesh instance.

Parameters

Note that translation, scaling, and direction can also be given using a Point instance.
translation : (dx, dy, dz), optional
The translation in world units of the created world object. scaling: (sx, sy, sz), optional The scaling in world units of the created world object. direction: (nx, ny, nz), optional Normal vector that indicates the direction of the created world object. rotation: scalar, optional The anle (in degrees) to rotate the created world object around its direction vector.
axesAdjust : bool
If True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the bars in the given axes, or the current axes if not given.

Create or return axes in current figure. Note that subplot(322) is the same as subplot(3,2,2).

Parameters

ncols : int
The number of columns to devide the figure in.
nrows : int
The number of rows to devide the figure in.
nr : int
The subfigure number on the grid specified by ncols and nrows. Should be at least one. subplot(221) is the top left. subplot(222) is the top right.

Notes

It is checked whether (the center of) an axes is present at the specified grid location. If so, that axes is returned. Otherwise a new axes is created at that location.

Shaded surface plot.

Usage
* surf(Z) - create a surface using the given image with z coordinates. * surf(Z, C) - also supply a texture image to map. * surf(X, Y, Z) - give x, y and z coordinates. * surf(X, Y, Z, C) - also supply a texture image to map.

Parameters

Z : A MxN 2D array

X : A length N 1D array, or a MxN 2D array

Y : A length M 1D array, or a MxN 2D array

C : A MxN 2D array, or a AxBx3 3D array
If 2D, C specifies a colormap index for each vertex of Z. If 3D, C gives a RGB image to be mapped over Z. In this case, the sizes of C and Z need not match.

Keyword arguments

axesAdjust : bool
If axesAdjust==True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Also see grid()

Show title above axes. Remove title by suplying an empty string.

Parameters

text : string
The text to display.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Use the specified backend and return an App instance that has a Run() method to enter the GUI toolkit's mainloop, and a ProcessEvents() method to process any GUI events.

This function is only required to explicitly choose a specific backend, or to obtain the application object; when this function is not used, vv.figure() will select a backend automatically.

Backend selection

If no backend is given, returns the previously selected backend. If no backend was yet selected, a suitable backend is selected automatically. This is done by detecting whether any of the backend toolkits is already loaded. If not, visvis tries to load the vv.settings.preferredBackend first.

Note: the backend can be changed even when figures are created with another backend, but this is not recommended.

Example embedding in Qt4

# Near the end of the script:

# Get app instance and create native app
app = vv.use('pyside')
app.Create()

# Create window
m = MainWindow()
m.resize(560, 420)
m.show()

# Run main loop
app.Run()

Get or set the view parameters for the given axes.

Parameters

viewparams : dict
View parameters to set.
axes : Axes instance
The axes the view parameters are for. Uses the current axes by default. keyword pairs View parameters to set. These take precidence.

If neither viewparams or any keyword pairs are given, returns the current view parameters (as a dict). Otherwise, sets the view parameters given.

Read volume from a file. If filename is 'stent', read a dedicated test dataset. For reading any other kind of volume, the imageio package is required.

Display a 3D image (a volume).

This is a convenience function that calls either volshow3() or volshow2(). If the current system supports it (OpenGL version >= 2.0), displays a 3D rendering (volshow3). Otherwise shows three slices that can be moved interactively (volshow2).

Parameters

vol : numpy array
The 3D image to visualize. Can be grayscale, RGB, or RGBA. If the volume is an anisotropic array (vv.Aaray), the appropriate scale and translate transformations are applied.
clim : 2-element tuple
The color limits to scale the intensities of the image. If not given, the im.min() and im.max() are used (neglecting nan and inf).
cm : Colormap
Set the colormap to apply in case the volume is grayscale.
axesAdjust : bool
If axesAdjust==True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Any other keyword arguments are passed to either volshow2() or volshow3().

Display a 3D image (a volume) using three slice textures that can be moved interactively. Returns a SliceTextureProxy instance that "wraps" the three SliceTexture instances.

Parameters

vol : numpy array
The 3D image to visualize. Can be grayscale, RGB, or RGBA. If the volume is an anisotropic array (vv.Aaray), the appropriate scale and translate transformations are applied.
clim : 2-element tuple
The color limits to scale the intensities of the image. If not given, the im.min() and im.max() are used (neglecting nan and inf).
renderStyle : not used
This parameter is included for compatibility with volshow3. Its value is ignored.
cm : Colormap
Set the colormap to apply in case the volume is grayscale.
axesAdjust : bool
If axesAdjust==True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Display a 3D image (a volume) using volume rendering, and returns the Texture3D object.

Parameters

vol : numpy array
The 3D image to visualize. Can be grayscale, RGB, or RGBA. If the volume is an anisotropic array (vv.Aaray), the appropriate scale and translate transformations are applied.
clim : 2-element tuple
The color limits to scale the intensities of the image. If not given, the im.min() and im.max() are used (neglecting nan and inf).
renderStyle : {'mip', 'iso', 'ray'}
The render style to use. Maximum intensity projection (default), isosurface rendering (using lighting), raycasting.
cm : Colormap
Set the colormap to apply in case the volume is grayscale.
axesAdjust : bool
If axesAdjust==True, this function will call axes.SetLimits(), and set the camera type to 3D. If daspectAuto has not been set yet, it is set to False.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Set the xlabel of an axes. Note that you can also use "axes.axis.xLabel = text".

Parameters

text : string
The text to display.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Set the ylabel of an axes. Note that you can also use "axes.axis.yLabel = text".

Parameters

text : string
The text to display.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

Set the zlabel of an axes. Note that you can also use "axes.axis.zLabel = text".

Parameters

text : string
The text to display.
axes : Axes instance
Display the image in this axes, or the current axes if not given.

⚠️ **GitHub.com Fallback** ⚠️