PlotlyBackend#
- class ansys.tools.visualization_interface.backends.plotly.plotly_interface.PlotlyBackend#
Bases:
ansys.tools.visualization_interface.backends._base.BaseBackendPlotly interface for visualization.
Overview#
Plot multiple objects using Plotly. |
|
Plot a single object using Plotly. |
|
Render the Plotly scene. |
|
Add point markers to the scene. |
|
Add line segments to the scene. |
|
Add a plane to the scene. |
|
Add text to the scene. |
|
Add labels at 3D point locations. |
|
Clear all traces from the figure. |
Get the current layout of the Plotly figure. |
Import detail#
from ansys.tools.visualization_interface.backends.plotly.plotly_interface import PlotlyBackend
Property detail#
- property PlotlyBackend.layout: Any#
Get the current layout of the Plotly figure.
- Returns:
AnyThe current layout of the Plotly figure.
Method detail#
- PlotlyBackend.plot_iter(plotting_list: Iterable[Any]) None#
Plot multiple objects using Plotly.
- Parameters:
- plotting_list
Iterable[Any] An iterable of objects to plot.
- plotting_list
- PlotlyBackend.plot(plottable_object: pyvista.PolyData | pyvista.MultiBlock | ansys.tools.visualization_interface.types.mesh_object_plot.MeshObjectPlot | plotly.graph_objects.Mesh3d, name: str = None, **plotting_options) None#
Plot a single object using Plotly.
- Parameters:
- plottable_object
Union[PolyData,pv.MultiBlock,MeshObjectPlot,go.Mesh3d] The object to plot. Can be a PyVista PolyData, MultiBlock, a MeshObjectPlot, or a Plotly Mesh3d.
- plotting_options
dict Additional plotting options.
- name
str,optional Name of the mesh for labeling in Plotly. Overrides the name from MeshObjectPlot if provided.
- plottable_object
- PlotlyBackend.show(plottable_object=None, screenshot: str = None, name_filter=None, **kwargs) plotly.graph_objects.Figure | None#
Render the Plotly scene.
- Parameters:
- Returns:
Union[go.Figure,None]The figure of the plot if in doc building environment. Else, None.
- PlotlyBackend.add_points(points: List | Any, color: str = 'red', size: float = 10.0, **kwargs) Any#
Add point markers to the scene.
- Parameters:
- Returns:
go.Scatter3dPlotly Scatter3d trace representing the added points.
- PlotlyBackend.add_lines(points: List | Any, connections: List | Any | None = None, color: str = 'white', width: float = 1.0, **kwargs) Any#
Add line segments to the scene.
- Parameters:
- points
Union[List,Any] Points defining the lines. Expected format: [[x1, y1, z1], [x2, y2, z2], …] or Nx3 array.
- connections
Optional[Union[List,Any]], default:None Line connectivity. If None, connects points sequentially. Expected format: [[start_idx1, end_idx1], [start_idx2, end_idx2], …] or Mx2 array.
- color
str, default: “white” Color of the lines.
- width
float, default: 1.0 Width of the lines.
- **kwargs
dict Additional keyword arguments passed to Plotly’s Scatter3d.
- points
- Returns:
Union[go.Scatter3d,List[go.Scatter3d]]Plotly Scatter3d trace(s) representing the added lines.
- PlotlyBackend.add_planes(center: Tuple[float, float, float] = (0.0, 0.0, 0.0), normal: Tuple[float, float, float] = (0.0, 0.0, 1.0), i_size: float = 1.0, j_size: float = 1.0, **kwargs) Any#
Add a plane to the scene.
- Parameters:
- center
Tuple[float,float,float], default: (0.0, 0.0, 0.0) Center point of the plane (x, y, z).
- normal
Tuple[float,float,float], default: (0.0, 0.0, 1.0) Normal vector of the plane (x, y, z).
- i_size
float, default: 1.0 Size of the plane in the i direction.
- j_size
float, default: 1.0 Size of the plane in the j direction.
- **kwargs
dict Additional keyword arguments passed to Plotly’s Mesh3d (e.g., color, opacity).
- center
- Returns:
go.Mesh3dPlotly Mesh3d trace representing the added plane.
- PlotlyBackend.add_text(text: str, position: Tuple[float, float] | Tuple[float, float, float] | str, font_size: int = 12, color: str = 'white', **kwargs) Any#
Add text to the scene.
- Parameters:
- text
str Text string to display.
- position
Union[Tuple[float,float],Tuple[float,float,float],str] Position for the text as 2D screen coordinates (x, y). Values should be between 0 and 1 for normalized coordinates, or pixel values for absolute positioning.
- font_size
int, default: 12 Font size for the text.
- color
str, default: “white” Color of the text.
- **kwargs
dict Additional keyword arguments passed to Plotly’s annotation.
- text
- Returns:
dictPlotly annotation representing the added text.