Skip to content

Commit 3ff9026

Browse files
authored
Update basic plotting example (#1290)
* Update basic plotting as Premium is default * Remove notebook argument from kwargs to prevent useless warning
1 parent df3e45d commit 3ff9026

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

examples/06-plotting/00-basic_plotting.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,20 @@
7474
# ##############################################################################################
7575
# # This next section requires a Premium context to be active du to the ``split_mesh`` operator.
7676
# # Comment this last part to run the example as Entry.
77-
#
78-
# dpf.SERVER.apply_context(dpf.AvailableServerContexts.premium)
79-
#
80-
# # One can also plot a MeshesContainer. Here our mesh is split by material.
81-
# split_mesh_op = dpf.Operator("split_mesh")
82-
# split_mesh_op.connect(7, mesh)
83-
# split_mesh_op.connect(13, "mat")
84-
# meshes_cont = split_mesh_op.get_output(0, dpf.types.meshes_container)
85-
# meshes_cont.plot(title='Meshes Container', text='Meshes Container plot')
86-
# # A fields_container can be given as input, with results on each part of our split mesh.
87-
# disp_op = dpf.Operator("U")
88-
# disp_op.connect(7, meshes_cont)
89-
# ds = dpf.DataSources(examples.find_multishells_rst())
90-
# disp_op.connect(4, ds)
91-
# disp_fc = disp_op.outputs.fields_container()
92-
# meshes_cont.plot(disp_fc, title='Meshes Container disp_fc', text='Meshes Container disp_fc plot')
93-
# # Additional PyVista kwargs are supported, such as:
94-
# meshes_cont.plot(off_screen=True, notebook=False, screenshot='meshes_cont_plot.png',
95-
# title='Meshes Container', text='Meshes Container plot')
77+
78+
# One can also plot a MeshesContainer. Here our mesh is split by material.
79+
split_mesh_op = dpf.Operator("split_mesh")
80+
split_mesh_op.connect(7, mesh)
81+
split_mesh_op.connect(13, "mat")
82+
meshes_cont = split_mesh_op.get_output(0, dpf.types.meshes_container)
83+
meshes_cont.plot(title='Meshes Container', text='Meshes Container plot')
84+
# A fields_container can be given as input, with results on each part of our split mesh.
85+
disp_op = dpf.Operator("U")
86+
disp_op.connect(7, meshes_cont)
87+
ds = dpf.DataSources(examples.find_multishells_rst())
88+
disp_op.connect(4, ds)
89+
disp_fc = disp_op.outputs.fields_container()
90+
meshes_cont.plot(disp_fc, title='Meshes Container disp_fc', text='Meshes Container disp_fc plot')
91+
# Additional PyVista kwargs are supported, such as:
92+
meshes_cont.plot(off_screen=True, notebook=False, screenshot='meshes_cont_plot.png',
93+
title='Meshes Container', text='Meshes Container plot')

src/ansys/dpf/core/meshed_region.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ def plot(
583583
show_axes=kwargs.pop("show_axes", True),
584584
**kwargs,
585585
)
586+
kwargs.pop("notebook", None)
586587
return pl.show_figure(**kwargs)
587588

588589
def deep_copy(self, server=None):

src/ansys/dpf/core/meshes_container.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def plot(self, fields_container=None, deform_by=None, scale_factor=1.0, **kwargs
114114
**kwargs,
115115
)
116116
# Plot the figure
117+
kwargs.pop("notebook", None)
117118
return pl.show_figure(**kwargs)
118119

119120
def get_meshes(self, label_space):

src/ansys/dpf/core/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ def plot(self, color="w", show_edges=True, **kwargs):
237237
kwargs["show_edges"] = show_edges
238238
pl = DpfPlotter(**kwargs)
239239
pl.add_mesh(self.metadata.meshed_region, show_axes=kwargs.pop("show_axes", True), **kwargs)
240+
kwargs.pop("notebook", None)
240241
return pl.show_figure(**kwargs)
241242

242243
@property

0 commit comments

Comments
 (0)