Skip to content

Commit f8e2507

Browse files
AlejandroFernandezLucespyansys-ci-botSMoraisAnsys
authored
feat: Improve optional arguments in show (#306)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Sébastien Morais <[email protected]>
1 parent 448dcd8 commit f8e2507

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Feat: improve optional arguments in `show`

src/ansys/tools/visualization_interface/backends/pyvista/pyvista.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ def show(
412412
view_2d: Dict = None,
413413
name_filter: str = None,
414414
dark_mode: bool = False,
415-
**plotting_options,
415+
plotting_options: Optional[Dict[str, Any]] = {},
416+
**show_options: Dict[str, Any],
416417
) -> List[Any]:
417418
"""Plot and show any PyAnsys object.
418419
@@ -431,9 +432,11 @@ def show(
431432
Regular expression with the desired name or names to include in the plotter.
432433
dark_mode : bool, default: False
433434
Whether to use dark mode for the widgets.
434-
**plotting_options : dict, default: None
435+
plotting_options : dict, default: None
435436
Keyword arguments. For allowable keyword arguments, see the
436437
:meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method.
438+
**show_options : Any
439+
Additional keyword arguments for the show method.
437440
438441
Returns
439442
-------
@@ -476,7 +479,7 @@ def show(
476479
# Update all buttons/widgets
477480
[widget.update() for widget in self._widgets]
478481

479-
self.show_plotter(screenshot, **plotting_options)
482+
self.show_plotter(screenshot, **show_options)
480483

481484
picked_objects_list = []
482485
if isinstance(plottable_object, list):
@@ -512,8 +515,7 @@ def show_plotter(self, screenshot: Optional[str] = None, **kwargs) -> None:
512515
visualizer.set_scene(self._pl)
513516
visualizer.show()
514517
else:
515-
jupyter_backend = kwargs.pop("jupyter_backend", None)
516-
self.pv_interface.show(screenshot=screenshot, jupyter_backend=jupyter_backend)
518+
self.pv_interface.show(screenshot=screenshot, **kwargs)
517519

518520
pv.OFF_SCREEN = self._pv_off_screen_original
519521

tests/test_generic_plotter.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,15 @@ def test_dark_mode():
178178
pl = Plotter()
179179
pl.plot(sphere)
180180
pl.show(dark_mode=True)
181+
182+
183+
def test_plotter_show_mix():
184+
"""Test mixing plot and show methods."""
185+
pl = Plotter()
186+
sphere = pv.Sphere()
187+
sphere1 = pv.Sphere(center=(0, 0, 1))
188+
# Plot
189+
pl.plot(sphere1, opacity=0.5, color="blue")
190+
191+
# Mix plot and show
192+
pl.show(sphere, plotting_options={"show_edges": True}, cpos="xy")

0 commit comments

Comments
 (0)