PyAnsys Tools Visualization Interface

raw JSON →
0.12.1 verified Fri May 01 auth: no python

A Python visualization interface for PyAnsys libraries, providing a unified API for plotting mesh objects and scalar/vector fields with backends like PyVista and Plotly. Current version 0.12.1 (stable), with pre-release 1.0.0a1 available. Release cadence is monthly.

pip install ansys-tools-visualization-interface
error ModuleNotFoundError: No module named 'ansys'
cause The package is not installed or the import path uses hyphens incorrectly.
fix
Install the package: pip install ansys-tools-visualization-interface. Then import with underscores: from ansys.tools.visualization_interface import ...
error AttributeError: module 'ansys.tools.visualization_interface' has no attribute 'Plotter'
cause The import statement is incorrect; the Plotter class is not a top-level attribute of the module.
fix
Use: from ansys.tools.visualization_interface import Plotter
error ValueError: Unsupported backend 'plotly' – only 'pyvista' is supported.
cause Plotly backend is an optional dependency and not installed by default.
fix
Install with plotly support: pip install ansys-tools-visualization-interface[plotly]
breaking The v1.0.0a1 pre-release introduces breaking changes in the API. The `Plotter` class and backend interfaces have been refactored. Existing code using v0.12.x may not work with v1.0.0a1 without migration.
fix Review the migration guide at https://github.com/ansys/ansys-tools-visualization-interface/blob/main/doc/source/migration_guide.rst before upgrading.
deprecated The `add_scalar_field` method in v0.12.x is deprecated and will be removed in v1.0.0. Use `add_field` instead.
fix Replace `add_scalar_field(...)` with `add_field(scalar_data=..., ...)`.
gotcha Backend selection must be done at initialization; you cannot switch backends after creating a Plotter instance.
fix Pass backend='pyvista' or backend='plotly' to Plotter constructor.

Basic example creating a triangular mesh and displaying it using the default backend.

from ansys.tools.visualization_interface import Plotter
import numpy as np

# Create a simple mesh
points = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]])
cells = np.array([[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]])
cell_types = np.array([5, 5, 5, 5])  # Triangle

# Initialize plotter and add mesh
plotter = Plotter()
plotter.add_mesh(points, cells, cell_types)
plotter.show()