Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/ansys/dpf/post/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,23 @@ def __repr__(self):
"""Representation of the DataFrame."""
return f"DataFrame<index={self.index}, columns={self.columns}>"

def plot(self, shell_layer=shell_layers.top, **kwargs) -> Union[DpfPlotter, None]:
def plot(
self,
shell_layer=shell_layers.top,
deform_by: Union[DataFrame, None] = None,
scale_factor: float = 1.0,
**kwargs,
) -> Union[DpfPlotter, None]:
"""Plot the result.

Parameters
----------
shell_layer:
Shell layer to show if multi-layered shell data is present. Defaults to top.
deform_by: # TODO: switch to deform as bool and use self._disp_wf as in animate
A DataFrame containing a 3D vector field to use for deformation of the mesh.
scale_factor:
Scaling factor to apply when deforming the mesh. Defaults to 1.0.
**kwargs:
This function accepts as argument any of the Index names available associated with a
single value.
Expand Down Expand Up @@ -852,7 +862,12 @@ def plot(self, shell_layer=shell_layers.top, **kwargs) -> Union[DpfPlotter, None
field_to_plot, server=field_to_plot._server
).eval()
plotter = DpfPlotter(**kwargs)
plotter.add_field(field=field_to_plot, **kwargs)
deform = None
if isinstance(deform_by, DataFrame):
deform = deform_by._fc
plotter.add_field(
field=field_to_plot, deform_by=deform, scale_factor=scale_factor, **kwargs
)

return plotter.show_figure(
title=kwargs.pop("title", str(label_space)), **kwargs
Expand Down