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

Update basic plotting example #1290

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
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
36 changes: 17 additions & 19 deletions examples/06-plotting/00-basic_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,20 @@
# ##############################################################################################
# # This next section requires a Premium context to be active du to the ``split_mesh`` operator.
# # Comment this last part to run the example as Entry.
#
# dpf.SERVER.apply_context(dpf.AvailableServerContexts.premium)
#
# # One can also plot a MeshesContainer. Here our mesh is split by material.
# split_mesh_op = dpf.Operator("split_mesh")
# split_mesh_op.connect(7, mesh)
# split_mesh_op.connect(13, "mat")
# meshes_cont = split_mesh_op.get_output(0, dpf.types.meshes_container)
# meshes_cont.plot(title='Meshes Container', text='Meshes Container plot')
# # A fields_container can be given as input, with results on each part of our split mesh.
# disp_op = dpf.Operator("U")
# disp_op.connect(7, meshes_cont)
# ds = dpf.DataSources(examples.find_multishells_rst())
# disp_op.connect(4, ds)
# disp_fc = disp_op.outputs.fields_container()
# meshes_cont.plot(disp_fc, title='Meshes Container disp_fc', text='Meshes Container disp_fc plot')
# # Additional PyVista kwargs are supported, such as:
# meshes_cont.plot(off_screen=True, notebook=False, screenshot='meshes_cont_plot.png',
# title='Meshes Container', text='Meshes Container plot')

# One can also plot a MeshesContainer. Here our mesh is split by material.
split_mesh_op = dpf.Operator("split_mesh")
split_mesh_op.connect(7, mesh)
split_mesh_op.connect(13, "mat")
meshes_cont = split_mesh_op.get_output(0, dpf.types.meshes_container)
meshes_cont.plot(title='Meshes Container', text='Meshes Container plot')
# A fields_container can be given as input, with results on each part of our split mesh.
disp_op = dpf.Operator("U")
disp_op.connect(7, meshes_cont)
ds = dpf.DataSources(examples.find_multishells_rst())
disp_op.connect(4, ds)
disp_fc = disp_op.outputs.fields_container()
meshes_cont.plot(disp_fc, title='Meshes Container disp_fc', text='Meshes Container disp_fc plot')
# Additional PyVista kwargs are supported, such as:
meshes_cont.plot(off_screen=True, notebook=False, screenshot='meshes_cont_plot.png',
title='Meshes Container', text='Meshes Container plot')
1 change: 1 addition & 0 deletions src/ansys/dpf/core/meshed_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ def plot(
show_axes=kwargs.pop("show_axes", True),
**kwargs,
)
kwargs.pop("notebook", None)
return pl.show_figure(**kwargs)

def deep_copy(self, server=None):
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/meshes_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def plot(self, fields_container=None, deform_by=None, scale_factor=1.0, **kwargs
**kwargs,
)
# Plot the figure
kwargs.pop("notebook", None)
return pl.show_figure(**kwargs)

def get_meshes(self, label_space):
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def plot(self, color="w", show_edges=True, **kwargs):
kwargs["show_edges"] = show_edges
pl = DpfPlotter(**kwargs)
pl.add_mesh(self.metadata.meshed_region, show_axes=kwargs.pop("show_axes", True), **kwargs)
kwargs.pop("notebook", None)
return pl.show_figure(**kwargs)

@property
Expand Down