# dolfin¶

FEniCS/Dolfin support submodule.

Install with commands (e.g. in Anaconda3):

conda install -c conda-forge fenics
pip install vtkplotter


Basic example:

import dolfin

plot(mesh)


Find many more examples in vtkplotter/examples/dolfin

## Latex¶

vtkplotter.dolfin.Latex(formula, pos=(0, 0, 0), c='k', s=1, bg=None, alpha=1, res=30, usetex=False, fromweb=False)[source]

Render Latex formulas.

Parameters: formula (str) – latex text string pos (list) – position coordinates in space c – face color bg – background color box res (int) – dpi resolution usetex (bool) – use latex compiler of matplotlib fromweb – retrieve the latex image from online server (codecogs)

You can access the latex formula from the Actor object with actor.info[‘formula’].

## MeshActor¶

class vtkplotter.dolfin.MeshActor(*inputobj, **options)[source]

MeshActor, a vtkActor derived object for dolfin support.

move(u=None)[source]

## MeshArrows¶

vtkplotter.dolfin.MeshArrows(*inputobj, **options)[source]

Build arrows representing displacements.

Parameters: s (float) – cross-section size of the arrow rescale (float) – apply a rescaling factor to the length

## MeshLines¶

vtkplotter.dolfin.MeshLines(*inputobj, **options)[source]

Build the line segments between two lists of points startPoints and endPoints. startPoints can be also passed in the form [[point1, point2], ...].

A dolfin Mesh that was deformed/modified by a function can be passed together as inputs.

Parameters: scale (float) – apply a rescaling factor to the length

## MeshPoints¶

vtkplotter.dolfin.MeshPoints(*inputobj, **options)[source]

Build a point Actor for a list of points.

Parameters: r (float) – point radius. c (int, str, list) – color name, number, or list of [R,G,B] colors of same length as plist. alpha (float) – transparency in range [0,1].

## Plotter¶

class vtkplotter.dolfin.Plotter(shape=(1, 1), N=None, pos=(0, 0), size='auto', screensize='auto', title='', bg='blackboard', bg2=None, axes=4, infinity=False, sharecam=True, verbose=True, interactive=None, offscreen=False, depthpeeling=False, qtWidget=None)[source]

Bases: object

Main class to manage actors.

Parameters: shape (list) – shape of the grid of renderers in format (rows, columns). Ignored if N is specified. N (int) – number of desired renderers arranged in a grid automatically. pos (list) – (x,y) position in pixels of top-left corner of the rendering window on the screen size – size of the rendering window. If ‘auto’, guess it based on screensize. screensize – physical size of the monitor screen bg – background color or specify jpg image file name with path bg2 – background color of a gradient towards the top axes (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.

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
• 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
Parameters: infinity (bool) – if True fugue point is set at infinity (no perspective effects) sharecam (bool) – if False each renderer will have an independent vtkCamera interactive (bool) – if True will stop after show() to allow interaction w/ window offscreen (bool) – if True will not show the rendering window depthpeeling (bool) – depth-peel volumes along with the translucent geometry qtWidget (QVTKRenderWindowInteractor) – render in a Qt-Widget using an QVTKRenderWindowInteractor. Overrides offscreen to True Overides interactive to False Sets setting.usingQt to True See Also: example qt_windows.py

add(actors, render=True)[source]

Append input object to the internal list of actors to be shown.

Returns: returns input actor for possible concatenation.
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

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, [4], 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 3 letters 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, [False], show a gridded wall on plane zx
• zxGrid2, [False], show zx plane on opposite side of the bounding box
• xyPlaneColor, [‘gray’], color of gridded 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
• 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, # ... } ) 
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, e.g. [‘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
addCutterTool(actor)[source]

Create handles to cut away parts of a mesh.

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

Add an inset icon mesh into the same 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 square inset.
addLegend()[source]
addLight(pos=(1, 1, 1), focalPoint=(0, 0, 0), deg=90, ambient=None, diffuse=None, specular=None, showsource=False)[source]

Generate a source of light placed at pos, directed to focal point fp.

Parameters: fp (vtkActor, list) – focal Point, if this is a vtkActor use its position. deg – aperture angle of the light source showsource – if True, will show a vtk representation of the source of light as an extra actor

Hint

lights.py

addScalarBar(actor=None, c=None, title='', horizontal=False, vmin=None, vmax=None)[source]

Add a 2D scalar bar for the specified actor.

If actor is None will add it to the last actor in self.actors.

addScalarBar3D(obj=None, at=0, pos=(0, 0, 0), normal=(0, 0, 1), sx=0.1, sy=2, nlabels=9, ncols=256, cmap=None, c=None, alpha=1)[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.
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
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
clear(actors=())[source]

Delete specified list of actors, by default delete all.

close()[source]
closeWindow()[source]

Close the current or the input rendering window.

getActors(obj=None, renderer=None)[source]

Return an actors list (which may include Volume objects too).

If obj is:

None, return actors of current renderer

int, return actors in given renderer number

vtkAssembly return the contained actors

string, return actors matching legend name

Parameters: renderer (int,vtkRenderer) – specify which renederer to look into.
getVolumes(obj=None, renderer=None)[source]

Return the list of the rendered Volumes.

If obj is:

None, return volumes of current renderer

int, return volumes in given renderer number

Parameters: renderer (int,vtkRenderer) – specify which renederer to look into.
load(inputobj, c=None, alpha=1, threshold=False, spacing=(), unpack=True)[source]

Load Actors and Volumes from file. The output will depend on the file extension. See examples below.

Parameters: c – color in RGB format, hex, symbol or name alpha – transparency (0=invisible)

For volumetric data (tiff, slc, vti etc): :param float threshold: value to draw the isosurface, False by default to return a Volume :param list spacing: specify the voxel spacing in the three dimensions :param bool unpack: only for multiblock data, if True returns a flat list of objects.

Example: from vtkplotter import datadir, load, show # Return an Actor g = load(datadir+'ring.gmsh') show(g) # Return a list of 2 Actors g = load([datadir+'250.vtk', datadir+'290.vtk']) show(g) # Return a list of actors by reaading all files in a directory # (if directory contains DICOM files then a Volume is returned) g = load(datadir+'timecourse1d/') show(g) # Return a Volume. Color/Opacity transfer function can be specified too. g = load(datadir+'embryo.slc') g.c(['y','lb','w']).alpha((0.0, 0.4, 0.9, 1)) show(g) # Return an Actor from a SLC volume with automatic thresholding g = load(datadir+'embryo.slc', threshold=True) show(g) 
moveCamera(camstart, camstop, fraction)[source]

Takes as input two vtkCamera objects and returns a new vtkCamera that is at an intermediate position:

fraction=0 -> camstart, fraction=1 -> camstop.

Press shift-C key in interactive mode to dump a python snipplet of parameters for the current camera view.

remove(actors)[source]

Remove vtkActor or actor index from current renderer.

show(*actors, **options)[source]

Render a list of actors.

Allowed input objects are: filename, vtkPolyData, vtkActor, vtkActor2D, vtkImageActor, vtkAssembly or vtkVolume.

If filename is given, its type is guessed based on its extension. Supported formats are: vtu, vts, vtp, ply, obj, stl, 3ds, xml, neutral, gmsh, pcd, xyz, txt, byu, tif, slc, vti, mhd, png, jpg.

Parameters: at (int) – number of the renderer to plot to, if more than one exists axes (int) – set the type of axes to be shown 0, no axes, 1, draw three customizable 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 c – surface color, in rgb, hex or name formats bc – set a color for the internal surface face wire (bool) – show actor in wireframe representation azimuth/elevation/roll (float) – move camera accordingly viewup (str) – either [‘x’, ‘y’, ‘z’] or a vector to set vertical direction resetcam (bool) – re-adjust camera position to fit objects camera (dict) – Camera parameters can further be specified with a dictionary assigned to the camera keyword (E.g. show(camera={‘pos’:(1,2,3), ‘thickness’:1000,})) pos, (list), the position of the camera in world coordinates focalPoint (list), the focal point of the camera in world coordinates viewup (list), the view up direction for the camera distance (float), set the focal point to the specified distance from the camera position. clippingRange (float), distance of the near and far clipping planes along the direction of projection. parallelScale (float), scaling used for a parallel projection, i.e. the height of the viewport in world-coordinate distances. The default is 1. Note that the “scale” parameter works as an “inverse scale”, larger numbers produce smaller images. This method has no effect in perspective projection mode. thickness (float), set the distance between clipping planes. This method adjusts the far clipping plane to be set a distance ‘thickness’ beyond the near clipping plane. viewAngle (float), the camera view angle, which is the angular height of the camera view measured in degrees. The default angle is 30 degrees. This method has no effect in parallel projection mode. The formula for setting the angle up for perfect perspective viewing is: angle = 2*atan((h/2)/d) where h is the height of the RenderWindow (measured by holding a ruler up to your screen) and d is the distance from your eyes to the screen. interactive (bool) – pause and interact with window (True) or continue execution (False) rate (float) – maximum rate of show() in Hertz interactorStyle (int) – set the type of interaction 0, TrackballCamera 1, TrackballActor 2, JoystickCamera 3, Unicam 4, Flight 5, RubberBand3D 6, RubberBandZoom q (bool) – force program to quit after show() command returns.
showInset(*actors, **options)[source]

Add a draggable inset space into a 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 square inset. draggable (bool) – if True the subrenderer space can be dragged around.

## ProgressBar¶

class vtkplotter.dolfin.ProgressBar(start, stop, step=1, c=None, ETA=True, width=24, char='▬')[source]

Bases: object

Class to print a progress bar with optional text message.

Example: import time pb = ProgressBar(0,400, c='red') for i in pb.range(): time.sleep(.1) pb.print('some message') # or pb.print(counts=i) 
len()[source]

Return the number of steps.

print(txt='', counts=None)[source]

Print the progress bar and optional message.

range()[source]

Return the range iterator.

## Text¶

vtkplotter.dolfin.Text(txt, pos='top-left', s=1, depth=0.1, justify='bottom-left', c=None, alpha=1, bc=None, bg=None, font='courier', followcam=False)[source]

Returns an Actor that shows a 2D/3D text.

Parameters: pos (list, int) – position in 3D space, a 2D text is placed in one of the 8 positions: 1, bottom-left 2, bottom-right 3, top-left 4, top-right 5, bottom-middle 6, middle-right 7, middle-left 8, top-middle If a pair (x,y) is passed as input the 2D text is place at that position in the coordinate system of the 2D screen (with the origin sitting at the bottom left). s (float) – size of text. depth (float) – text thickness. justify (str) – text justification (bottom-left, bottom-right, top-left, top-right, centered). bg – background color of corner annotations. Only applies of pos is int. font (str) – additional available fonts are: Ageo Aldora CallingCode Godsway Gula ImpactLabel Komiko Lamborgini MidnightDrive Militech MonaShark Montserrat MyDisplaySt PointedLaidSt SchoolTeacher SpecialElite Font choice does not apply for 3D text. A path to otf or ttf font-file can also be supplied as input. All fonts are free for personal use. Check out conditions in vtkplotter/fonts/licenses for commercial use and: https://www.1001freefonts.com followcam (bool, vtkCamera) – if True the text will auto-orient itself to the active camera. A vtkCamera object can also be passed.

Hint

## Video¶

class vtkplotter.dolfin.Video(name='movie.avi', **kwargs)[source]

Bases: object

Class to generate a video from the specified rendering window. Program ffmpeg is used to create video from each generated frame. :param str name: name of the output file. :param int fps: set the number of frames per second. :param float duration: set the total duration of the video and recalculates fps accordingly. :param str ffmpeg: set path to ffmpeg program. Default value considers ffmpeg is in the path.

addFrame()[source]

close()[source]

Render the video and write to file.

pause(pause=0)[source]

Insert a pause, in seconds.

## closePlotter¶

vtkplotter.dolfin.closePlotter()[source]

Close the current instance of Plotter and its rendering window.

## closeWindow¶

vtkplotter.dolfin.closeWindow(plotterInstance=None)[source]

Close the current or the input rendering window.

## embedWindow¶

vtkplotter.dolfin.embedWindow(backend='k3d', verbose=True)[source]

## exportWindow¶

vtkplotter.dolfin.exportWindow(fileoutput, binary=False, speed=None, html=True)[source]

Exporter which writes out the renderered scene into an OBJ, X3D or Numpy file. X3D is an XML-based format for representation 3D scenes (similar to VRML). Check out http://www.web3d.org/x3d for more details.

Parameters: speed (float) – set speed for x3d files. html (bool) – generate a test html page for x3d files.

generated webpage

## interactive¶

vtkplotter.dolfin.interactive()[source]

Go back to the rendering window interaction mode.

vtkplotter.dolfin.load(inputobj, c=None, alpha=1, threshold=False, spacing=(), unpack=True)[source]

Load Actor and Volume from file.

The output will depend on the file extension. See examples below.

Parameters: c – color in RGB format, hex, symbol or name alpha – transparency/opacity of the polygonal data.

For volumetric data (tiff, slc, vti etc..):

Parameters: c (list) – can be a list of any length of colors. This list represents the color transfer function values equally spaced along the range of the volumetric scalar. alpha (list) – can be a list of any length of tranparencies. This list represents the transparency transfer function values equally spaced along the range of the volumetric scalar. threshold (float) – value to draw the isosurface, False by default to return a Volume. If set to True will return an Actor with automatic choice of the isosurfacing threshold. spacing (list) – specify the voxel spacing in the three dimensions unpack (bool) – only for multiblock data, if True returns a flat list of objects. from vtkplotter import datadir, load, show # Return an Actor g = load(datadir+'250.vtk') show(g) # Return a list of 2 Actors g = load([datadir+'250.vtk', datadir+'270.vtk']) show(g) # Return a list of actors by reading all files in a directory # (if directory contains DICOM files then a Volume is returned) g = load(datadir+'timecourse1d/') show(g) # Return a Volume. Color/Opacity transfer functions can be specified too. g = load(datadir+'embryo.slc') g.c(['y','lb','w']).alpha((0.0, 0.4, 0.9, 1)) show(g) # Return an Actor from a SLC volume with automatic thresholding g = load(datadir+'embryo.slc', threshold=True) show(g) 

## plot¶

vtkplotter.dolfin.plot(*inputobj, **options)[source]

Plot the object(s) provided.

Input can be: vtkActor, vtkVolume, dolfin.Mesh, dolfin.MeshFunction*, dolfin.Expression or dolfin.Function.

Returns: the current Plotter class instance. mode (str) – one or more of the following can be combined in any order mesh/color, will plot the mesh, by default colored with a scalar if available warp, mesh will be modified by a displacement function contour, to be implemented arrows, mesh displacements are plotted as scaled arrows. lines, mesh displacements are plotted as scaled lines. tensors, to be implemented add (bool) – add the input objects without clearing the already plotted ones density (float) – show only a subset of lines or arrows [0-1] wire[frame] (bool) – visualize mesh as wireframe [False] c[olor] – set mesh color [None] exterior (bool) – only show the outer surface of the mesh [False] alpha (float) – set object’s transparency [1] lw (float) – line width of the mesh (set to zero to hide mesh) [0.5] ps (float) – set point size of mesh vertices [None] z (float) – add a constant to z-coordinate (useful to show 2D slices as function of time) legend (str) – add a legend to the top-right of window [None] scalarbar (bool) – add a scalarbar to the window [‘vertical’] vmin (float) – set the minimum for the range of the scalar [None] vmax (float) – set the maximum for the range of the scalar [None] scale (float) – add a scaling factor to arrows and lines sizes [1] cmap (str) – choose a color map for scalars bands (int) – group colors in n bands shading (str) – mesh shading [‘flat’, ‘phong’, ‘gouraud’] text (str) – add a gray text comment to the top-left of the window [None] isolines (dict) – dictionary of isolines properties n, (int) - add this number of isolines to the mesh c, - isoline color lw, (float) - isoline width z, (float) - add to the isoline z coordinate to make them more visible warpZfactor (float) – elevate z-axis by scalar value (useful for 2D geometries) warpYfactor (float) – elevate z-axis by scalar value (useful for 1D geometries) scaleMeshFactors (list) – rescale mesh by these factors [1,1,1] newPlotter (bool) – spawn a new instance of Plotter class, pops up a new window at (int) – renderer number to plot to shape (list) – subdvide window in (n,m) rows and columns N (int) – automatically subdvide window in N renderers pos (list) – (x,y) coordinates of the window position on screen size – window size (x,y) title (str) – window title bg – background color name of window bg2 – second background color name to create a color gradient style (int) – choose a predefined style [0-4] 0, vtkplotter, style (blackboard background, rainbow color map) 1, matplotlib, style (white background, viridis color map) 2, paraview, style 3, meshlab, style 4, bw, black and white style. axes (int) – axes type number 0, no axes, 1, draw three customizable gray grid walls. See show() documentation. 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. infinity (bool) – if True fugue point is set at infinity (no perspective effects) sharecam (bool) – if False each renderer will have an independent vtkCamera interactive (bool) – if True will stop after show() to allow interaction w/ window depthpeeling (bool) – depth-peel volumes along with the translucent geometry offscreen (bool) – if True will not show the rendering window zoom (float) – camera zooming factor viewup – camera view-up direction [‘x’,’y’,’z’, or a vector direction] azimuth (float) – add azimuth rotation of the scene, in degrees elevation (float) – add elevation rotation of the scene, in degrees roll (float) – add roll-type rotation of the scene, in degrees camera (dict) – Camera parameters can further be specified with a dictionary assigned to the camera keyword: (E.g. show(camera={‘pos’:(1,2,3), ‘thickness’:1000,})) pos, (list), the position of the camera in world coordinates focalPoint (list), the focal point of the camera in world coordinates viewup (list), the view up direction for the camera distance (float), set the focal point to the specified distance from the camera position. clippingRange (float), distance of the near and far clipping planes along the direction of projection. parallelScale (float), scaling used for a parallel projection, i.e. the height of the viewport in world-coordinate distances. The default is 1. Note that the “scale” parameter works as an “inverse scale”, larger numbers produce smaller images. This method has no effect in perspective projection mode. thickness (float), set the distance between clipping planes. This method adjusts the far clipping plane to be set a distance ‘thickness’ beyond the near clipping plane. viewAngle (float), the camera view angle, which is the angular height of the camera view measured in degrees. The default angle is 30 degrees. This method has no effect in parallel projection mode. The formula for setting the angle up for perfect perspective viewing is: angle = 2*atan((h/2)/d) where h is the height of the RenderWindow (measured by holding a ruler up to your screen) and d is the distance from your eyes to the screen. interactorStyle (int) – change the style of muose interaction of the scene q (bool) – exit python session after returning.

## plotMatrix¶

vtkplotter.dolfin.plotMatrix(M, title='matrix', continuous=True, cmap='Greys')[source]
Plot a matrix using matplotlib.
Example: from vtkplotter.dolfin import plotMatrix import numpy as np M = np.eye(9) + np.random.randn(9,9)/4 plotMatrix(M) 

## printHistogram¶

vtkplotter.dolfin.printHistogram(data, 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 Actor. Returns the raw data before binning (useful when passing vtk objects).

Parameters: 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 np 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 

## printc¶

vtkplotter.dolfin.printc(*strings, **keys)[source]

Print to terminal in colors. (python3 only).

Available colors are:
black, red, green, yellow, blue, magenta, cyan, white.
Parameters: c – foreground color bc – background color hidden (bool) – do not show text [False] bold (bool) – boldface [True] italic (bool) – italic [False] blink (bool) – blinking text [False] underline (bool) – underline text [False] strike (bool) – strike through text [False] dim (bool) – make text look dimmer [False] invert (bool) – invert background anf forward colors [False] box – print a box with specified text character [‘’] flush (bool) – flush buffer after printing [True] end (str) – end character to be printed [newline] from vtkplotter.colors import printc printc('anything', c='red', bold=False, end='' ) printc('anything', 455.5, vtkObject, c='green') printc(299792.48, c=4) # 4 is blue 

Hint

printc.py

## screenshot¶

vtkplotter.dolfin.screenshot(filename='screenshot.png')[source]

Save a screenshot of the current rendering window.

## show¶

vtkplotter.dolfin.show(*actors, **options)[source]

Create on the fly an instance of class Plotter and show the object(s) provided.

Allowed input objects are: filename, vtkPolyData, vtkActor, vtkActor2D, vtkImageActor, vtkAssembly or vtkVolume.

If filename is given, its type is guessed based on its extension. Supported formats are: vtu, vts, vtp, ply, obj, stl, 3ds, xml, neutral, gmsh, pcd, xyz, txt, byu, tif, slc, vti, mhd, png, jpg.

Parameters: at (int) – number of the renderer to plot to, if more than one exists axes (int) – set the type of axes to be shown 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 c – surface color, in rgb, hex or name formats bc – set a color for the internal surface face wire (bool) – show actor in wireframe representation azimuth/elevation/roll (float) – move camera accordingly viewup (str) – either [‘x’, ‘y’, ‘z’] or a vector to set vertical direction resetcam (bool) – re-adjust camera position to fit objects camera (dict) – Camera parameters can further be specified with a dictionary assigned to the camera keyword (E.g. show(camera={‘pos’:(1,2,3), ‘thickness’:1000,})): pos, (list), the position of the camera in world coordinates focalPoint (list), the focal point of the camera in world coordinates viewup (list), the view up direction for the camera distance (float), set the focal point to the specified distance from the camera position. clippingRange (float), distance of the near and far clipping planes along the direction of projection. parallelScale (float), scaling used for a parallel projection, i.e. the height of the viewport in world-coordinate distances. The default is 1. Note that the “scale” parameter works as an “inverse scale”, larger numbers produce smaller images. This method has no effect in perspective projection mode. thickness (float), set the distance between clipping planes. This method adjusts the far clipping plane to be set a distance ‘thickness’ beyond the near clipping plane. viewAngle (float), the camera view angle, which is the angular height of the camera view measured in degrees. The default angle is 30 degrees. This method has no effect in parallel projection mode. The formula for setting the angle up for perfect perspective viewing is: angle = 2*atan((h/2)/d) where h is the height of the RenderWindow (measured by holding a ruler up to your screen) and d is the distance from your eyes to the screen. interactive (bool) – pause and interact with window (True) or continue execution (False) rate (float) – maximum rate of show() in Hertz interactorStyle (int) – set the type of interaction 0, TrackballCamera 1, TrackballActor 2, JoystickCamera 3, Unicam 4, Flight 5, RubberBand3D 6, RubberBandZoom q (bool) – force program to quit after show() command returns. 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.: readVolumeAsIsoSurface.py the current Plotter class instance.

Note

With multiple renderers, keyword at can become a list, e.g.

from vtkplotter import *
s = Sphere()
c = Cube()
p = Paraboloid()
show(s, c, at=[0, 1], shape=(3,1))
show(p, at=2, interactive=True)
#
# is equivalent to:
vp = Plotter(shape=(3,1))
s = Sphere()
c = Cube()
p = Paraboloid()
vp.show(s, at=0)
vp.show(p, at=1)
vp.show(c, at=2, interactive=True)