open_viewmin.filter_tree_plot.filter_tree_plot

Contents

open_viewmin.filter_tree_plot.filter_tree_plot#

Define class extending pyvista.Plotter with filter formulas and a filters tree

Classes#

FilterFormula

Class for reusable PyVista filters.

FilterTreePlot

PyVista Plotter with meshes organized into a "filter tree".

WidgetFormula

Class for creating re-usable widgets

Functions#

probe(mesh, sampled_points, **kwargs)

Workaround for PyVista's removal of probe filter

Module Contents#

class FilterFormula(plotter, name=None, parent_mesh_name=None, filter_callable=None, filter_kwargs=None, mesh_kwargs=None, random=None, has_actor=True, in_place=False, ovm_info=None, widget_name=None, apply_upon_creation=True, children=None, colorbar=None, **extra_filter_kwargs)#

Class for reusable PyVista filters.

Parameters:
  • plotter (FilterTreePlot) – Parent plotter

  • name (str or None) – Name of filter formula and its mesh. Pass None to default to plotter’s default mesh name.

  • parent_mesh_name (str or None) – Name of parent mesh. Pass None to default to plotter’s default mesh name.

  • filter_callable (callable(), str, or None) – Function of parent mesh that returns a callable, which when called applies a filter to (re-)create a child mesh. Pass None to use an “identity filter”, making the parent its own child.

  • filter_kwargs (dict or None, optional) – Dictionary of keyword arguments supplied to the function returned by filter_callable. None is equivalent to dict().

  • mesh_kwargs (dict or None, optional) – Dictionary of keyword arguments to pyvista.Plotter.add_mesh for customization of mesh visualization. None is equivalent to dict().

  • random (bool or None, optional) – Whether to use random sampling, if applicable.

  • has_actor (bool, optional) – Whether to create an actor visualizing the mesh.

  • in_place (bool, optional) – Whether to modify a mesh in-place rather than creating a child mesh.

  • ovm_info (dict or None) – Dictionary of keyword arguments for ad-hoc purposes. None is equivalent to dict().

  • widget_name (str or None) – Name of widget, if applicable, that creates this filter formula

  • apply_upon_creation (bool, optional) – Whether to apply the filter formula, creating its mesh, immediately upon creating the filter formula.

  • children (list of str, or None, optional) – List of names of child meshes. None is equivalent to [].

  • colorbar (VTK scalar bar actor or None, optional) – Existing colorbar actor, if applicable.

  • **extra_filter_kwargs (dict, optional) – Extra keyword arguments to append to filter_kwargs (for convenience).

__getitem__(key)#

Access mesh’s datasets in dictionary-like manner

__repr__()#

Print keyword arguments to FilterFormula and their current values

Return type:

str

__setitem__(key, set_to)#

Set mesh’s datasets in dictionary-like manner

_inherit(filter_kwarg)#

If this FilterFormula has no value currently assigned to filter_kwarg, try to inherit the value from an ancestor FilterFormula

Parameters:

filter_kwarg (str)

Return type:

inherited_filter_keyword_argument

_interpret_color_or_scalars(mesh_kwargs)#

Check if mesh coloring should be updated as a solid color or color array.

Parameters:

mesh_kwargs (dict) – Mesh visualizing settings

Returns:

Whether to update solid color, whether to update color array, and mesh visualizing settings dictionary

Return type:

(bool, bool, dict)

_remove_bad_mesh_kwargs(mesh_kwargs)#

Remove unexpected keyword arguments to pyvista.Plotter.add_mesh

Parameters:

mesh_kwargs (dict) – Mesh visualization settings

Returns:

Mesh visualization settings with bad keyword arguments removed

Return type:

dict

_update_actor_color_array()#

Visualize mesh with color array

_update_actor_solid_color()#

Visualize mesh with solid color

add_calculation(name, calc_callable)#

Create a data array for this mesh that is recalculated whenever the mesh is updated. The function accomplishing this is added to the FilterFormula’s do_after_update list.

Example: If we have a NematicPlot p, with a glyphs filter_formula called “director”, the following creates a scalar data array holding the normal component of the “director” orientation field.

>>> p["director"].add_calculation("normal_component", lambda a: np.inner(a.orientations, a.normal))

Equivalently, you can assign calc_callable as the value corresponding to key name:

>>> p["director"]["normal_component"] = lambda a: np.inner(a.orientations, a.normal)
Parameters:
  • name (str)

  • calc_callable (callable()) – Function mapping filter_formula to calculated data array.

add_filter(filter_callable, **kwargs)#

Create a callable that returns a filter formula whose parent mesh is this formula’s child mesh

Used for dictionary-style assignment of new filter formula to plotter.

Parameters:
  • filter_callable (callable()) – Function mapping new mesh name to new filter formula

  • kwargs (dict, optional) – Keyword arguments to FilterFormula

Return type:

callable()

add_glyphs(**kwargs)#

Create a glyphs child filter formula

Parameters:

kwargs (dict, optional)

Returns:

Function of new mesh name; adds glyphs filter formula

Return type:

callable()

color_by_active_scalars(categories=None)#

Set mesh’s color array to most recently used scalar dataset

Parameters:

categories (bool, optional)

get_auto_color()#

Get next color in plotter’s color sequence

Returns:

color rgb values

Return type:

tuple(float)

get_centroids(num_centroids=10, ref_pt_idx=0, mesh_name_to_probe=None)#

Add centroids filter formula

Child filter formula probes a given mesh at centroids calculated from the points of this filter formula’s mesh.

Parameters:
  • num_centroids (int, optional) – Number of centroids

  • ref_pt_idx (int, optional) – Index of starting point for calculating centroids

  • mesh_name_to_probe (str or None, optional) – Name of mesh to probe (source of datasets). Pass None to default to self.plotter.default_mesh_name.

Returns:

Name of sampled (child) mesh

Return type:

str

get_circuits(mesh_to_probe_name=None, normals_name=None, radius=3, n_samples=100, use_ints=False)#

Add circuits filter formula

Parameters:
  • mesh_to_probe_name (str) – Name of mesh to probe

  • normals_name (str or None, optional) – Name of vectors dataset defined on mesh_of_circuit_centers to be used as normal directions to circuits. Pass None to default to name of active_vectors dataset of parent mesh.

  • radius (float, optional) – Radius of each circuit

  • n_samples (int, optional) – Number of circuits

  • use_ints (bool, optional) – Whether to round coordinates of circuit points to integers

Returns:

Name of sampled (child) mesh, or None if no child mesh was created.

Return type:

str or None

get_eigenvec(tensors_name=None, evec_idx=-1, new_dataset_name=None)#

Calculate an eigenvector of symmetric second-rank tensor dataset

Parameters:
  • tensors_name (str or None, optional) – Name of symmetric rank-2 tensors dataset. Pass None to default to name of most recently created symmetric rank-2 tensors dataset.

  • evec_idx (int, optional) – Index of eigenvector to take, ordered by ascending eigenvalues

  • new_dataset_name (str or None) – Name of vector dataset storing eigenvector. Pass None to default to “_eigenvec” appended to tensors_name.

Return type:

numpy.ndarray

give_colorbar_unique_title()#

Check if color bar lacks a title, and assign one if so

Returns:

Color bar title

Return type:

str

static handle_filter_or_numpy(filter_result, parent_mesh, filter_name)#

Properly handle filter results that may be mesh or array

If the filter result is an array, assigns the filter result as a new dataset on a copy of the parent mesh.

Parameters:
  • filter_result (pyvista.dataset or numpy.ndarray) – Result of filter

  • parent_mesh (pyvista.dataset) – Parent mesh

  • filter_name (str) – Name for new dataset in case filter_result is an array.

Returns:

New child mesh

Return type:

pyvista.dataset

hide()#

Make mesh’s actor invisible

static identity_callable(mesh)#

Get a filter formula callable that simply copies the parent mesh

Parameters:

mesh (pyvista.dataset)

Return type:

callable()

make_sure_parent_knows_about_me()#

Make sure that this filter formula’s name is in the parent mesh filter formula’s list of children

remove_child_relationship_to_all_parents()#

Cause any meshes claiming this mesh as a child to forget that relationship, a prerequisite for deleting this mesh.

remove_colorbar()#

Remove color bar for this filter formula’s mesh

set(**mesh_kwargs)#

Shorthand for update_actor()

Parameters:

**mesh_kwargs – New or modified keyword arguments to pyvista.Plotter.add_mesh

Returns:

Updated actor

Return type:

vtkmodules.vtkRenderingOpenGL2.vtkOpenGLActor

set_glyph_shape(new_shape, **geom_args)#

Modify shape of glyphs

Parameters:
  • new_shape (str) – Shape name

  • geom_args (dict, optional) – Keyword arguments for shape

set_glyphs_scale(new_scale)#

Set global scale factor for glyphs

Parameters:

new_scale (float) – New scale factor

set_glyphs_stride(new_stride)#

Set spacing between glyphs

Parameters:

new_stride (int) – New spacing

static string_to_filter(filter_string)#

Convert filter name to callable

Convert string name of PyVista filter to a callable that produces that filter. If the argument is not a string, return the argument (for cases where the filter callable is passed rather than its string name).

Parameters:

filter_string (str or object)

Returns:

  • callable() – Function mapping existing mesh to a new mesh via the named filter.

  • object – If filter_string is not a string, returns filter_string

update(update_actor=True, ovm_info=None, **filter_kwargs)#

Update a mesh by calling its creator filter

Parameters:
  • update_actor (bool, optional) – Whether to update the actor visualizing the mesh

  • ovm_info (dict or None, optional) – New or modified items for mesh settings dictionary

  • **filter_kwargs – New or modified keyword arguments for filter callable

Returns:

Updated child mesh

Return type:

pyvista.dataset

update_actor(is_new=False, **mesh_kwargs)#

Update or create mesh visualizing actor

Parameters:
  • is_new (bool, optional) – Whether actor has just been created (to avoid duplicate warnings)

  • mesh_kwargs (dict, optional) – New or modified keyword arguments to pyvista.Plotter.add_mesh

Returns:

Updated actor

Return type:

vtkmodules.vtkRenderingOpenGL2.vtkOpenGLActor

update_children()#

Update child meshes

Calls update function of each filter formula named in self.children

property array_names#
Get mesh's dataset names
Return type:

list[str]

property is_filter_tree_root#
Check whether mesh is a root of the filter tree
Return type:

bool

property is_glyphs#
Check whether mesh is glyphs
Return type:

bool

property mesh#
Get child mesh
Return type:

pyvista.dataset

property normal#
Normal vector to plane
Return type:

numpy.ndarray

property orientations#
Get orientations data array for glyphs; `None` for non-glyphs
property origin#
Origin of plane
Return type:

numpy.ndarray

property parent_filter_formula#
Get parent mesh's filter formula
Return type:

FilterFormula

property parent_mesh#
Get parent mesh
Return type:

pyvista.dataset

property points#
Get mesh's points
Return type:

numpy.ndarray

property random#
Check whether random sampling has been selected
Return type:

bool

property root_ancestor#
root (possibly self) of filter tree from which this filter formula
property descends#
class FilterTreePlot(filenames=None, user_settings=None, theme=None, reader=ovm_utilities.fast_import, dims=None, data_stride=1, **kwargs)#

Bases: pyvista.Plotter

PyVista Plotter with meshes organized into a “filter tree”.

Updates to any mesh are automatically followed by updates to its child meshes and actors, recursively.

Parameters:
  • filenames (list[str], str, or None, optional) – Files to import.

  • user_settings (dict or None, optional) – Customizations to default plotter settings.

  • theme (['dark' | 'document' | 'paraview' | None], optional) – PyVista plot theme

  • reader (callable()) – Function to import and process data files

  • dims (tuple of ints or None, optional) – System dimensions used if no filenames are given.

  • data_stride (int, optional) – Spacing between grid sites used if no filenames are given.

  • kwargs (dict, optional) – Keyword arguments to pyvista.Plotter()

__getitem__(mesh_name)#

Mimic dictionary key-value behavior for mesh names and meshes.

Parameters:

mesh_name (str)

Return type:

FilterFormula

__repr__()#

Represent plotter as a textual representation of its filters tree.

Returns:

Textual representation of filters tree.

Return type:

str

__setitem__(mesh_name, filter_formula_lambda)#

Mimic dictionary key-value behavior for mesh names and meshes.

Parameters:
  • mesh_name (str)

  • filter_formula_lambda (callable()) – Callable that creates filter formula

Return type:

FilterFormula

_add_checkbox_generic(callback, current_val, size=50, position=None, color_on=None, **kwargs)#

Add checkbox

Parameters:
  • callback (callable)

  • current_val (bool)

  • size (int)

  • position (tuple(float), optional)

  • color_on (pyvista.plotting.colors.Color, optional)

  • kwargs – keyword arguments to :meth:pyvista.Plotter.add_checkbox_button_widget

_add_inplot_slider(callback, mesh_name, current_val=None, min_val=None, max_val=None, title=None, title_height=0.03, style='classic', label_height=0.03, pointa=None, pointb=None, loc='top right', **kwargs)#
Parameters:
  • callback (callable)

  • mesh_name (str)

  • current_val (float, optional)

  • min_val (float, optional)

  • max_val (float, optional)

  • title (str, optional)

  • title_height (float, optional)

  • style (str, optional) – Options in pyvista.global_theme.slider_styles

  • label_height (float)

  • pointa (tuple(float), optional)

  • pointb (tuple(float), optional)

  • loc (str, optional) – Slider location by keyword; options are “top left”, “bottom left”, “bottom right”. If any other string or None is given, slider is positioned in top right.

  • kwargs – keyword arguments to pyvista.Plotter.add_slider_widget()

Return type:

vtk.vtkSliderWidget

_set_pyvista_plotter_properties()#

Initialization choices for PyVista Plotter

_visibility_callback(actor_name)#
actor_names()#

Names of all actors in filters tree.

Returns:

List of actor names.

Return type:

list[str]

add_axes()#

Add x,y,z axes widget.

add_filter_formula(name=None, **kwargs)#

Add a filter formula to the plotter.

Parameters:
  • name (str or None, optional) – Name of new mesh. Pass None to do nothing.

  • **kwargs – Keyword arguments to FilterFormula

Returns:

New child mesh created by filter formula, or None if no filter formula was created.

Return type:

pyvista.dataset or None

add_isosurface_slider(mesh_name, min_val=None, max_val=None, title=None, title_height=0.02, style='classic', label_height=0.02, pointa=None, pointb=None, loc='top right', **kwargs)#

Add isosurface slider

Parameters:
  • mesh_name (str)

  • min_val (float, optional)

  • max_val (float, optional)

  • title (str, optional)

  • title_height (float)

  • style (str, optional) – Options in pyvista.global_theme.slider_styles

  • label_height (float, optional)

  • pointa (tuple(float), optional)

  • pointb (tuple(float), optional)

  • loc (str, optional) – Slider location by keyword; options are “top left”, “bottom left”, “bottom right”. If any other string or None is given, slider is positioned in top right.

  • kwargs – keyword arguments to _add_inplot_slider()

Return type:

vtk.vtkSliderWidget

add_plane_widget(*args, **kwargs)#

Overload add_plane_widget to take a string argument as name of mesh controlled by widget.

Parameters:
  • *args (tuple, optional)

  • **kwargs (dict, optional)

Return type:

vtkmodules.vtkInteractionWidgets.vtkImplicitPlaneWidget

add_root_mesh(mesh, mesh_name='fullmesh')#

Add a filter formula as a new root of the filter tree.

Parameters:
  • mesh (pyvista.DataSet) – PyVista mesh

  • mesh_name (str, optional) – Name of the new root mesh.

Returns:

Name of the new root mesh (possibly altered to avoid overwriting existing mesh names).

Return type:

str

add_threshold_slider(mesh_name, min_val=None, max_val=None, title=None, title_height=0.02, style='classic', label_height=0.02, pointa=None, pointb=None, loc='top right', **kwargs)#

Add slider for threshold

Parameters:
  • mesh_name (str)

  • min_val (float, optional)

  • max_val (float, optional)

  • title (str, optional)

  • title_height (float, optional)

  • style (str, optional) – Options in pyvista.global_theme.slider_styles

  • label_height (float, optional)

  • pointa (tuple(float), optional)

  • pointb (tuple(float), optional)

  • loc (str, optional) – Slider location by keyword; options are “top left”, “bottom left”, “bottom right”. If any other string or None is given, slider is positioned in top right.

  • kwargs – keyword arguments to _add_inplot_slider()

add_visibility_checkbox(actor_name, size=50, position=None, **kwargs)#

Add checkbox to toggle an actor’s visibility

Parameters:
  • actor_name (str)

  • size (int)

  • position (tuple(float), optional)

  • kwargs – Keyword arguments to _add_checkbox_generic()

add_widget_checkbox(widget_name, size=50, position=None, background_color='red', **kwargs)#

Add checkbox that activates/deactivates a widget

Parameters:
  • widget_name (str)

  • size (int)

  • position (tuple(float), optional)

  • background_color (str)

  • kwargs – Keyword arguments to _add_checkbox_generic()

add_widget_formula(name=None, **kwargs)#

Add a widget formula to the plotter.

Parameters:
  • name (str or None, optional) – Name of new widget. Pass None to do nothing.

  • **kwargs (dict, optional) – Keyword arguments to WidgetFormula

Returns:

The new widget formula, or None if none was created.

Return type:

WidgetFormula or None

array_dims()#

System array-size dimensions.

Returns:

(array_Lx, array_Ly, array_Lz)

Return type:

tuple(int)

assign_file_data_to_frame(file_data, filename, do_load_frame=True)#

Store data from a file as a new frame in the plotter’s timeseries data.

Parameters:
  • file_data (np.ndarray)

  • filename (str)

  • do_load_frame (bool, optional) – Whether to view the frame

colorbar_titles()#

Get titles of all scalar bars

Returns:

List of scalar bar titles

Return type:

list[str]

colorbars()#

Get list of all existing colorbars (scalar bars) for filter tree actors.

Return type:

list of VTK scalar bar actors

copy_all_actors(to_plotter)#

Copy actors to another plotter, such as for displaying in Jupyter notebooks.

Parameters:

to_plotter (pyvista.Plotter)

Return type:

None

create_fullmesh(dat=None, mesh_name='fullmesh', frame_num=None)#

Create a uniform grid mesh as a root mesh for the filter tree.

Parameters:
  • dat (np.ndarray, optional) – Data array, with first three columns holding integer coordinates X, Y, Z.

  • mesh_name (str, optional) – Name of root mesh.

  • frame_num (int or None, optional) – Frame number for this root mesh. Pass None to append as a new frame.

Returns:

Frame number and new root mesh.

Return type:

int, pyvista.dataset

dims()#

System linear dimensions.

Returns:

(Lx, Ly, Lz)

Return type:

tuple(int)

disable_eye_dome_lighting()#
disable_shadows()#
do_orbit()#

Move camera along orbit path

Removes actor named “orbit”, if it exists, before starting the motion.

enable_eye_dome_lighting()#
enable_shadows()#
extract_actors(jupyter_backend='trame')#

Set up a new PyVista plotter with a copy of all this plotter’s actors.

Parameters:

jupyter_backend (str, optional) – PyVista plotting backend. See https://docs.pyvista.org/version/stable/user-guide/themes.

Returns:

New PyVista Plotter containing this Plotter’s actors.

Return type:

pyvista.Plotter

filter_tree_roots()#

Names of meshes whose generating FilterFormula ‘s are roots of the filter tree

Return type:

list[str]

find_actor_for_scalar_bar(scalar_bar)#

Get the name of the filter tree mesh corresponding to a given scalar bar.

Parameters:

scalar_bar (VTK scalar bar actor)

Returns:

Mesh name

Return type:

str

first_frame()#

View first frame in data timeseries.

get_actor(actor_name)#

Return actor with a given name, if it exists.

Parameters:

actor_name (str) – Name of actor.

Returns:

PyVista actor.

Return type:

vtkmodules.vtkRenderingOpenGL2.vtkOpenGLActor

get_actor_name(actor)#

Given an actor, return its name.

Parameters:

actor (vtkOpenGLActor) – PyVista actor.

Returns:

Name of actor.

Return type:

str

get_filter_formula(actor_name)#

Get the formula needed to re-create an actor from its parent mesh.

Parameters:

actor_name (str) – Name of the actor.

Returns:

Actor recipe.

Return type:

types.SimpleNamespace

get_grandparent_mesh_name(actor_or_mesh_name)#

Get the name of the parent of the parent of a given actor or mesh.

Parameters:

actor_or_mesh_name (str) – Name of actor of mesh

Returns:

Name of grandparent mesh.

Return type:

str

get_mesh(mesh_name)#

Return mesh with a given name, if it exists. For non-mesh actors, return parent mesh.

Parameters:

mesh_name (str)

Returns:

PyVista mesh

Return type:

pyvista.DataSet

get_mesh_name(mesh)#

Get the name of a given mesh.

Parameters:

mesh (pyvista.DataSet)

Returns:

name of the mesh

Return type:

str

get_points()#

Get array of coordinates belonging to root mesh “fullmesh”

Returns:

Array of point coordinates.

Return type:

np.ndarray

get_widget(widget_name)#

Get widget by name

Parameters:

widget_name (str)

Return type:

vtkmodules.vtkInteractionWidgets.vtk3DWidget

get_widget_formula(widget_name)#

Get WidgetFormula by name

Parameters:

widget_name (str)

Return type:

WidgetFormula

hide_all_actors()#

Make all actors invisible

hide_all_meshes()#

Make actors of all meshes invisible

hide_orbit()#

Remove the mesh visualizing the camera orbit.

initialize_plotter(**kwargs)#

Run pyvista.Plotter initialization.

Note: This is removed from __init__() for purposes of multiple inheritance of NematicPlot.

last_frame()#

View last frame in data timeseries.

load(filenames, reader=ovm_utilities.fast_import, mpi_group=True, do_load_frame=True)#

Import a file or files.

Parameters:
  • filenames (str or list[str]) – Files to load.

  • reader (callable, optional) – Function to read each file.

  • mpi_group (bool, optional) – Whether to stitch files together as separate outputs from the same timestep from an MPI run.

  • do_load_frame (bool, optional) – Whether to view the frame containing the loaded data.

mesh_names()#

Names of all meshes in filters tree.

Returns:

List of mesh names.

Return type:

list[str]

name_mesh_without_overwriting(mesh_name)#

Modify a proposed new mesh name to be distinct from existing mesh names

Parameters:

mesh_name (str) – Proposed mesh name

Returns:

Distinct mesh name to use

Return type:

str

name_widget_without_overwriting(widget_name)#
Modify a proposed new widget name to be distinct from existing

widget names

Parameters:

widget_name (str) – Proposed widget name

Returns:

Distinct widget name to use

Return type:

str

next_frame()#

View next frame in data timeseries.

non_filter_tree_actor_names()#

List actors that don’t belong to open_viewmin’s filter tree.

Returns:

List of actor names.

Return type:

list[str]

num_frames()#

Number of frames in timeseries data.

static organize_filenames(filenames, mpi_group=True)#

For data to be imported, sort filenames alphabetically after grouping MPI files appropriately.

Parameters:
  • filenames (list[str] | str)

  • mpi_group (bool)

Return type:

list[str]

play(pause_time=0.5)#

In-GUI animation; will be slow because it loads and renders on the fly

previous_frame()#

View previous frame in data timeseries.

probe_at_picked_surface_point(result_name=None)#

Create a FilterFormula with the sample filter probing a picked mesh at a picked point

Parameters:

result_name (str, optional) – Name of new FilterFormula; defaults to “_probed” appended to name of picked mesh

Returns:

result_name – Name of new FilterFormula

Return type:

str

refresh()#

Re-apply all filter formulas to refresh meshes

remove_mesh_completely(mesh_name, remove_children=True)#

Remove a mesh (filter or actor) from the plotter and from the filters tree.

Parameters:
  • mesh_name (str) – Name of mesh to remove.

  • remove_children (bool, optional) – Whether to recursively remove all meshes descended from this mesh in the filters tree.

Return type:

None

rename_mesh(from_name, to_name, do_refresh=True)#

Copy a mesh in the filters tree by copying its recipe.

Parameters:
  • from_name (str) – Name of mesh to copy.

  • to_name (str) – Name of new mesh.

  • do_refresh (bool, optional) – Whether to create the mesh anew from its filter after renaming.

Return type:

None

save_meshes(file_prefix)#

Save all meshes to .vtk files

Parameters:

file_prefix (str) – File location will be [mesh_name].vtk appended to this.

scalar_fields(mesh_name='fullmesh')#

List names of datasets with one value at each site.

Parameters:

mesh_name (str or pyvista.DataSet) – PyVista mesh or its name.

Returns:

List of array names.

Return type:

list[str]

set_actor_visibility(actor, visibility: bool)#

Set visibility of a mesh or meshes

Parameters:
  • actor (str, sequence of str, VTK actor, or sequence of VTK actors)

  • visibility (bool) – Whether mesh(es) are to be visible.

set_background(*args, **kwargs)#

Set plotter’s background color(s)

If called with no arguments, retrieves color from FilterTreePlot.settings[“background_color”], defaulting to black. Otherwise, args and kwargs are sent to pyvista.Plotter.set_background.

Parameters:
  • args

  • kwargs

set_lights_intensity(intensity)#

Rescale intensity of all lights.

Parameters:

intensity (float)

set_orbit(**kwargs)#

Set orbit properties and get its camera locations

Parameters:

kwargs – keyword arguments to set_orbit_kwargs()

Returns:

Orbit points

Return type:

pyvista.core.pointset.PolyData

set_orbit_kwargs(factor=3.0, n_points=20, viewup=None, shift=0.0, step=0.1)#

Modify camera orbit

Parameters:
  • factor (float) – orbit radius relative to data extent

  • n_points (int) – number of points subdividing circle at which to generate images

  • viewup (iterable[float], optional) – orientation vector for camera’s up direction

  • shift (float) – translation of camera location along viewup

  • step (float) – orbit speed in seconds per frame

Returns:

vis – Visibility of orbit points actor

Return type:

bool

show_orbit()#

Add a mesh of points visualizing the camera orbit.

symmetric_tensor_fields(mesh_name='fullmesh')#

List names of datasets with nine values at each site, whose corresponding 3x3 matrix is everywhere symmetric.

Parameters:

mesh_name (str or pyvista.DataSet) – PyVista mesh or its name.

Returns:

List of array names.

Return type:

list[str]

tensor_fields(mesh_name='fullmesh')#

List names of datasets with nine values at each site.

Parameters:

mesh_name (str or pyvista.DataSet) – PyVista mesh or its name.

Returns:

List of array names.

Return type:

list[str]

static toggle_actor_visibility(actor)#

Toggle visibility of an actor

Parameters:

actor (VTK actor)

Returns:

new_visibility

Return type:

bool

toggle_eye_dome_lighting()#

Switch eye dome lighting on/off

toggle_filter_tree_actor_visibility(actor_name)#

Toggle visibility of a mesh in the filter tree.

Parameters:

actor_name (str) – Name of mesh

toggle_floor()#

Toggle visibility of floor (-z) plane.

toggle_last_colorbar()#

Toggle visibility of most recently modified colorbar.

toggle_orbit_visibility(toggle=True)#

Toggle visibility of mesh visualizing camera orbit.

toggle_scalar_bar_visibility(scalar_bar_actor)#

Toggle visibility of a scalar bar

Parameters:

scalar_bar_actor (VTK scalar bar actor)

toggle_shadows()#

Turn shadow rendering on/off

toggle_stereo_render()#

Turn anaglyph stereo 3D effect on/off

unique_array_names(mesh=None)#

Get array names for datasets attached to a mesh, deleting duplicates.

Parameters:

mesh (str or pyvista.DataSet) – PyVista mesh or name of mesh

Returns:

Mesh along with the list of unique array names.

Return type:

(pyvista.DataSet, list[str])

update_actor(actor_name, **kwargs)#

Update a filter formula’s mesh visualization options.

Shorthand for self.get_filter_formula(ellipsoid_mesh_name).set()

Parameters:
update_filter(mesh_name, update_actor=False, **kwargs)#

Update a filter formula.

Shorthand for self.get_filter_formula(parent_mesh_name).update().

Parameters:
vector_fields(mesh='fullmesh')#

List names of datasets with three values at each site.

Parameters:

mesh (str or pyvista.DataSet) – PyVista mesh or its name.

Returns:

List of array names.

Return type:

list[str]

view_frame(frame_num=0, keep_camera_dist=True)#

Use one of the (already imported) sets of data as the source for all PyVista meshes, e.g. for generating a frame of an animation from timeseries data.

Parameters:
  • frame_num (int, optional) – Index in self.data of the timeframe to display.

  • keep_camera_dist (bool, optional) – Whether to force camera to maintain position after frame load.

property default_mesh#
property fullmesh#
class WidgetFormula(plotter, name=None, mesh_name=None, enabled=True, callback=None, creator=None, configure=None, widget_args=None, **kwargs)#

Class for creating re-usable widgets

Parameters:
  • plotter (FilterTreePlot)

  • name (str or None) – Name of widget. Pass None to default to “_widget” appended to parent_mesh_name.

  • mesh_name (str or None) – Name of mesh controlled by widget. Pass None to default to plotter’s default mesh name.

  • enabled (bool, optional) – Whether to initialize widget as enabled.

  • callback (callable()) – Function mapping (plotter, parent_mesh_name) to a callable that applies the widget to update its mesh.

  • creator (callable()) – Function creating the widget. First argument must be a function of the kind created by callback(plotter, parent_mesh_name). Must also accept all arguments in widget_args and keyword arguments in kwargs.

  • configure (callable() or None, optional) – Function configuring a widget based on previously existing widget, mapping the widget to a two-element tuple (enabled: bool, widget_args: tuple). Pass None to ignore.

  • widget_args (tuple or None) – Positional arguments, besides callback, to creator. None is equivalent to empty tuple.

  • kwargs (dict, optional) – Keyword arguments to creator.

apply()#

Create the widget and apply it to create the mesh it controls

check_existing_widget_configuration()#

Get information to configure widget according to previous settings

Returns:

Whether widget is enabled; widget arguments.

Return type:

(bool, tuple)

get_creator_func()#

If self.creator is a string, get the corresponding callable

Return type:

callable()

set_color(*widget_color)#

Set widget color

Note that this does not control the color of any mesh.

Parameters:

widget_color (tuple) – Color as rgb floats, or as one-element tuple containing string of color name or hex value.

set_outline_visibility(visibility: int)#

Set visibility of a widget’s box outline

Parameters:

visibility (int) – Make outline visible unless visibility equals 0.

update()#

Update mesh controlled by widget.

Configure widget according to previous settings, then apply the widget’s callback.

property widget#
Get widget
Return type:

VTK widget

probe(mesh, sampled_points, **kwargs)#

Workaround for PyVista’s removal of probe filter

Essentially reverses the sample filter.

Parameters:
  • mesh (pyvista.DataSet)

  • sampled_points (numpy.ndarray or pyvista.pyvista_ndarray)

  • **kwargs – Keyword arguments to pyvista.DataSet.sample