Submodule extending the vtkActor, vtkVolume and vtkImageActor objects functionality.


class vtkplotter.base.ActorBase[source]

Bases: object

Adds functionality to Mesh(vtkActor), Assembly, Volume and Picture objects.


Do not use this class to instance objects, use the above ones.


Retrieve number of points. Shortcut for NPoints().


Retrieve number of cells.


Retrieve number of points. Same as N().

addCellScalars(scalars, name)[source]

Add cell scalars and assign it a name.

addCellVectors(vectors, name)[source]

Add a vector field to each object cell and assign it a name.

addPointScalars(scalars, name)[source]

Add point scalars and assign it a name.

addPointVectors(vectors, name)[source]

Add a point vector field to the object and assign it a name.

addPos(dp_x=None, dy=None, dz=None)[source]

Add vector to current object position.


Get the object bounds.


Return the bounding box as a new Mesh.


scale (float) – box size can be scaled by a factor



Draw axes on a Mesh or Volume. Returns a Assembly object.

  • xtitle, [‘x’], x-axis title text.

  • xrange, [None], x-axis range in format (xmin, ymin), default is automatic.

  • numberOfDivisions,[None], approximate number of divisions on the longest axis

  • axesLineWidth, [1], width of the axes lines

  • gridLineWidth, [1], width of the grid lines

  • reorientShortTitle, [True], titles shorter than 2 letter are placed horizontally

  • originMarkerSize, [0.01], draw a small cube on the axis where the origin is

  • titleDepth, [0], extrusion fractional depth of title text

  • xyGrid, [True], show a gridded wall on plane xy

  • yzGrid, [True], show a gridded wall on plane yz

  • zxGrid, [True], show a gridded wall on plane zx

  • zxGrid2, [False], show zx plane on opposite side of the bounding box

  • xyGridTransparent [False], make grid plane completely transparent

  • xyGrid2Transparent [False], make grid plane completely transparent on opposite side box

  • xyPlaneColor, [‘gray’], color of the plane

  • xyGridColor, [‘gray’], grid line color

  • xyAlpha, [0.15], grid plane opacity

  • showTicks, [True], show major ticks

  • xTitlePosition, [0.32], title fractional positions along axis

  • xTitleOffset, [0.05], title fractional offset distance from axis line

  • xTitleJustify, [“top-right”], title justification

  • xTitleRotation, [0], add a rotation of the axis title

  • xLineColor, [automatic], color of the x-axis

  • xTitleColor, [automatic], color of the axis title

  • xTitleBackfaceColor, [None], color of axis title on its backface

  • xTitleSize, [0.025], size of the axis title

  • xHighlightZero, [True], draw a line highlighting zero position if in range

  • xHighlightZeroColor, [automatic], color of the line highlighting the zero position

  • xTickRadius, [0.005], radius of the major ticks

  • xTickThickness, [0.0025], thickness of the major ticks along their axis

  • xTickColor, [automatic], color of major ticks

  • xMinorTicks, [1], number of minor ticks between two major ticks

  • tipSize, [0.01], size of the arrow tip

  • xPositionsAndLabels [], assign custom tick positions and labels [(pos1, label1), …]

  • xLabelPrecision, [2], nr. of significative digits to be shown

  • xLabelSize, [0.015], size of the numeric labels along axis

  • xLabelOffset, [0.025], offset of numeric labels

  • limitRatio, [0.04], below this ratio don’t plot small axis

from vtkplotter import Box, show

b = Box(pos=(1,2,3), length=8, width=9, height=7).alpha(0)
bax = b.buildAxes(c='white')  # returns Assembly object

show(b, bax)


Shortcut for color(). If None is passed as input, will use colors from current active scalars.


Get the coordinates of the cell centers.


Get the length of the diagonal of mesh bounding box.


Add a flag label which becomes visible when hovering the object with mouse. Can be later disabled by setting flag(False).


Return cell array content as a numpy.array.


Return point array content as a numpy.array. This can be identified either as a string or by an integer number.


Check if info['transform'] exists and returns a vtkTransform. Otherwise return current user transformation (where the object is currently placed).


Return the VTK input data object.


Set/get Mesh legend text.


txt (str) – legend text.

Size and positions can be modified by setting attributes Plotter.legendSize, Plotter.legendBC and Plotter.legendPos.

lighting(style='', ambient=None, diffuse=None, specular=None, specularPower=None, specularColor=None, enabled=True)[source]

Set the ambient, diffuse, specular and specularPower lighting constants.

  • style (str,int) – preset style, can be [metallic, plastic, shiny, glossy, ambient]

  • ambient (float) – ambient fraction of emission [0-1]

  • diffuse (float) – emission of diffused light in fraction [0-1]

  • specular (float) – fraction of reflected light [0-1]

  • specularPower (float) – precision of reflection [1-100]

  • specularColor (color) – color that is being reflected by the surface

  • enabled (bool) – enable/disable all surface light emission



Transform cell data (i.e., data specified per cell) into point data (i.e., data specified at each vertex). The method of transformation is based on averaging the data values of all cells using a particular point.


Transform point data (i.e., data specified per point) into cell data (i.e., data specified per cell). The method of transformation is based on averaging the data values of all points defining a particular cell.


Return the vtkMapper data object, or update it with a new one.


Get the maximum dimension in x, y or z of the bounding box.


Switch off object visibility. Object is not removed.


Switch on object visibility. Object is not removed.

orientation(newaxis=None, rotation=0, rad=False)[source]

Set/Get object orientation.

  • rotation – If != 0 rotate object around newaxis.

  • rad – set to True if angle is in radians.

origin(x=None, y=None, z=None)[source]

Set/get object’s origin. Relevant to control the scaling with scale() and rotations. Has no effect on position.


Set/get pickable property of mesh.

pos(x=None, y=None, z=None)[source]

Set/Get object position.


Print Mesh, Assembly, Volume or Image infos.

printHistogram(bins=10, height=10, logscale=False, minbin=0, horizontal=False, char='▉', c=None, bold=True, title='Histogram')[source]

Ascii histogram printing. Input can also be Volume or Mesh. Returns the raw data before binning (useful when passing vtk objects).

  • bins (int) – number of histogram bins

  • height (int) – height of the histogram in character units

  • logscale (bool) – use logscale for frequencies

  • minbin (int) – ignore bins before minbin

  • horizontal (bool) – show histogram horizontally

  • char (bool) – character to be used

  • c (str,int) – ascii color

  • char – use boldface

  • title (str) – histogram title

from vtkplotter import printHistogram
import numpy as np
d = np.random.normal(size=1000)
data = printHistogram(d, c='blue', logscale=True, title='my scalars')
data = printHistogram(d, c=1, horizontal=1)
print(np.mean(data)) # data here is same as d



Print information about a vtk object.

rotate(angle, axis=(1, 0, 0), axis_point=(0, 0, 0), rad=False)[source]

Rotate around an arbitrary axis passing through axis_point.

rotateX(angle, rad=False)[source]

Rotate around x-axis. If angle is in radians set rad=True.

rotateY(angle, rad=False)[source]

Rotate around y-axis. If angle is in radians set rad=True.

rotateZ(angle, rad=False)[source]

Rotate around z-axis. If angle is in radians set rad=True.

scale(s=None, absolute=False)[source]

Set/get object’s scaling factor.

  • list s (float,) – scaling factor(s).

  • absolute (bool) – if True previous scaling factors are ignored.


if s=(sx,sy,sz) scale differently in the three coordinates.


Transform object position and orientation.


Create on the fly an instance of class Plotter or use the last existing one to show one single object.

This is meant as a shortcut. If more than one object needs to be visualised please use the syntax show([mesh1, mesh2, volume, …], options).


newPlotter (bool) – if set to True, a call to show will instantiate a new Plotter object (a new window) instead of reusing the first created. See e.g.:


the current Plotter class instance.



from vtkplotter import *
s = Sphere(), N=2)
c = Cube(), interactive=True)

Set/get object’s absolute time.


Set/Get object position along x axis.


Get the bounds [xmin,xmax].


Set/Get object position along y axis.


Get the bounds [ymin,ymax].


Set/Get object position along z axis.


Get the bounds [zmin,zmax].