Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DataFrame.plot(deform) #587

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
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 @@ -712,13 +712,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 @@ -850,7 +860,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
Loading