Themes#

PyVista plotting parameters can be controlled on a plot by plot basis or through a global theme, making it possible to control mesh colors and styles through one global configuration.

The DocumentTheme is the default theme for PyVista. Theme provides a theme that is similar to the default styling of VTK.

See Control Global and Local Plotting Themes for an example on how to use themes within PyVista.

themes.DarkTheme()

Dark mode theme.

themes.Theme()

Base VTK theme.

themes.DocumentTheme()

A document theme well suited for papers and presentations.

themes.ParaViewTheme()

A paraview-like theme.

themes._AxesConfig()

PyVista axes configuration.

themes._CameraConfig()

PyVista camera configuration.

themes._ColorbarConfig()

PyVista colorbar configuration.

themes._DepthPeelingConfig()

PyVista depth peeling configuration.

themes._Font()

PyVista plotter font configuration.

themes._LightingConfig()

PyVista lighting configuration.

themes._SilhouetteConfig()

PyVista silhouette configuration.

themes._SliderConfig()

PyVista configuration encompassing all slider styles.

themes._SliderStyleConfig()

PyVista configuration for a single slider style.

themes._TrameConfig()

PyVista Trame configuration.

Custom Interactor Styles#

Themes can also choose the default interactor style by name through Theme.interactor_style. Downstream packages can register additional style names programmatically or through the pyvista.interactor_styles entry-point group.

register_interactor_style(name: str, handler: InteractorStyleHandler) None[source]#

Register a custom interactor style.

Parameters:
namestr

Name of the interactor style. Built-in PyVista styles use names that mirror the public enable_*_style API, such as 'terrain_style'.

handlercallable()

Handler for the interactor style. This can be a vtkInteractorStyle subclass (instantiated automatically) or any callable with signature handler(interactor) that returns an interactor style instance.

Raises:
ValueError

If name is empty or collides with a built-in PyVista interactor style.

Examples

Register a vtkInteractorStyle subclass directly and use it from a theme.

>>> import pyvista as pv
>>> from vtkmodules.vtkInteractionStyle import (
...     vtkInteractorStyleFlight,
... )
>>> pv.register_interactor_style(
...     'flight_style', vtkInteractorStyleFlight
... )
>>> pv.global_theme.interactor_style = 'flight_style'

A callable that takes the interactor as an argument can also be registered.

>>> def custom_style(interactor): ...
>>> pv.register_interactor_style(
...     'custom_style', custom_style
... )