addons

Additional objects like axes, legends etc..

addAxes

vtkplotter.addons.addAxes(axtype=None, c=None)[source]

Draw axes on scene. Available axes types:

Parameters:axtype (int) –
  • 0, no axes,
  • 1, draw three gray grid walls
  • 2, show cartesian axes from (0,0,0)
  • 3, show positive range of cartesian axes from (0,0,0)
  • 4, show a triad at bottom left
  • 5, show a cube at bottom left
  • 6, mark the corners of the bounding box
  • 7, draw a simple ruler at the bottom of the window
  • 8, show the vtkCubeAxesActor object
  • 9, show the bounding box outLine
  • 10, show three circles representing the maximum bounding box
  • 11, show polar axes

Axis type-1 can be fully customized by passing a dictionary axes=dict() where:

  • xtitle, [‘x’], x-axis title text.
  • ytitle, [‘y’], y-axis title text.
  • ztitle, [‘z’], z-axis title text.
  • numberOfDivisions, [automatic], number of divisions on the shortest 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
  • enableLastLabel, [False], show last numeric label on axes
  • 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
  • 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
Example:
from vtkplotter import Box, show
b = Box(pos=(0,0,0), length=80, width=90, height=70).alpha(0)

show(b, axes={ 'xtitle':'Some long variable [a.u.]',
               'numberOfDivisions':4,
               # ...
             }
)

customAxes.py customAxes.py

addButton

vtkplotter.addons.addButton(fnc, states=('On', 'Off'), c=('w', 'w'), bc=('dg', 'dr'), pos=(20, 40), size=24, font='arial', bold=False, italic=False, alpha=1, angle=0)[source]

Add a button to the renderer window.

Parameters:
  • states (list) – a list of possible states [‘On’, ‘Off’]
  • c – a list of colors for each state
  • bc – a list of background colors for each state
  • pos – 2D position in pixels from left-bottom corner
  • size – size of button font
  • font (str) – font type (arial, courier, times)
  • bold (bool) – bold face (False)
  • italic (bool) – italic face (False)
  • alpha (float) – opacity level
  • angle (float) – anticlockwise rotation in degrees

buttons.py buttons.py

addCutterTool

vtkplotter.addons.addCutterTool(actor)[source]

Create handles to cut away parts of a mesh.

cutter.py cutter.py

addIcon

vtkplotter.addons.addIcon(iconActor, pos=3, size=0.08)[source]

Add an inset icon mesh into the renderer.

Parameters:
  • pos – icon position in the range [1-4] indicating one of the 4 corners, or it can be a tuple (x,y) as a fraction of the renderer size.
  • size (float) – size of the icon space.

icon icon.py

addLegend

vtkplotter.addons.addLegend()[source]

addLight

vtkplotter.addons.addLight(pos, focalPoint=(0, 0, 0), deg=180, c='white', intensity=0.4, removeOthers=False, showsource=False)[source]

Generate a source of light placed at pos, directed to focal point. Returns a vtkLight object.

Parameters:
  • focalPoint – focal point, if this is a vtkActor use its position.
  • deg – aperture angle of the light source
  • c – set light color
  • intensity (float) – intensity between 0 and 1.
  • removeOthers (bool) – remove all other lights in the scene
  • showsource (bool) – if True, will show a representation of the source of light as an extra Actor

Hint

lights.py

addScalarBar

vtkplotter.addons.addScalarBar(actor, pos=(0.8, 0.05), title='', titleXOffset=0, titleYOffset=15, titleFontSize=12, nlabels=10, c=None, horizontal=False, vmin=None, vmax=None)[source]

Add a 2D scalar bar for the specified actor.

addScalarBar3D

vtkplotter.addons.addScalarBar3D(obj, pos=(0, 0, 0), normal=(0, 0, 1), sx=0.1, sy=2, title='', titleXOffset=-1.5, titleYOffset=0.0, titleSize=1.5, titleRotation=0.0, nlabels=9, prec=3, labelOffset=0.4, c=None, alpha=1, cmap=None)[source]

Draw a 3D scalar bar.

obj input can be:
  • a list of numbers,
  • a list of two numbers in the form (min, max),
  • a vtkActor already containing a set of scalars associated to vertices or cells,
  • if None the last actor in the list of actors will be used.
Parameters:
  • sx (float) – thickness of scalarbar
  • sy (float) – length of scalarbar
  • title (str) – scalar bar title
  • titleXOffset (float) – horizontal space btw title and color scalarbar
  • titleYOffset (float) – vertical space offset
  • titleSize (float) – size of title wrt numeric labels
  • titleRotation (float) – title rotation in degrees
  • nlabels (int) – number of numeric labels
  • prec (int) – number of significant digits
  • labelOffset (float) – space btw numeric labels and scale
  • cmap (str) – specify cmap to be used

addSlider2D

vtkplotter.addons.addSlider2D(sliderfunc, xmin, xmax, value=None, pos=4, title='', c=None, showValue=True)[source]

Add a slider widget which can call an external custom function.

Parameters:
  • sliderfunc – external function to be called by the widget
  • xmin (float) – lower value
  • xmax (float) – upper value
  • value (float) – current value
  • pos (list) – position corner number: horizontal [1-4] or vertical [11-14] it can also be specified by corners coordinates [(x1,y1), (x2,y2)]
  • title (str) – title text
  • showValue (bool) – if true current value is shown

sliders.py sliders.py

addSlider3D

vtkplotter.addons.addSlider3D(sliderfunc, pos1, pos2, xmin, xmax, value=None, s=0.03, title='', rotation=0, c=None, showValue=True)[source]

Add a 3D slider widget which can call an external custom function.

Parameters:
  • sliderfunc – external function to be called by the widget
  • pos1 (list) – first position coordinates
  • pos2 (list) – second position coordinates
  • xmin (float) – lower value
  • xmax (float) – upper value
  • value (float) – initial value
  • s (float) – label scaling factor
  • title (str) – title text
  • c – slider color
  • rotation (float) – title rotation around slider axis
  • showValue (bool) – if True current value is shown

sliders3d.py sliders3d.py