diff --git a/doc/changelog.d/306.miscellaneous.md b/doc/changelog.d/306.miscellaneous.md new file mode 100644 index 00000000..d337884a --- /dev/null +++ b/doc/changelog.d/306.miscellaneous.md @@ -0,0 +1 @@ +Feat: improve optional arguments in `show` \ No newline at end of file diff --git a/src/ansys/tools/visualization_interface/backends/pyvista/pyvista.py b/src/ansys/tools/visualization_interface/backends/pyvista/pyvista.py index d70af00f..499a2a88 100644 --- a/src/ansys/tools/visualization_interface/backends/pyvista/pyvista.py +++ b/src/ansys/tools/visualization_interface/backends/pyvista/pyvista.py @@ -412,7 +412,8 @@ def show( view_2d: Dict = None, name_filter: str = None, dark_mode: bool = False, - **plotting_options, + plotting_options: Optional[Dict[str, Any]] = {}, + **show_options: Dict[str, Any], ) -> List[Any]: """Plot and show any PyAnsys object. @@ -431,9 +432,11 @@ def show( Regular expression with the desired name or names to include in the plotter. dark_mode : bool, default: False Whether to use dark mode for the widgets. - **plotting_options : dict, default: None + plotting_options : dict, default: None Keyword arguments. For allowable keyword arguments, see the :meth:`Plotter.add_mesh ` method. + **show_options : Any + Additional keyword arguments for the show method. Returns ------- @@ -476,7 +479,7 @@ def show( # Update all buttons/widgets [widget.update() for widget in self._widgets] - self.show_plotter(screenshot, **plotting_options) + self.show_plotter(screenshot, **show_options) picked_objects_list = [] if isinstance(plottable_object, list): @@ -512,8 +515,7 @@ def show_plotter(self, screenshot: Optional[str] = None, **kwargs) -> None: visualizer.set_scene(self._pl) visualizer.show() else: - jupyter_backend = kwargs.pop("jupyter_backend", None) - self.pv_interface.show(screenshot=screenshot, jupyter_backend=jupyter_backend) + self.pv_interface.show(screenshot=screenshot, **kwargs) pv.OFF_SCREEN = self._pv_off_screen_original diff --git a/tests/test_generic_plotter.py b/tests/test_generic_plotter.py index cab27d2b..f6c28862 100644 --- a/tests/test_generic_plotter.py +++ b/tests/test_generic_plotter.py @@ -178,3 +178,15 @@ def test_dark_mode(): pl = Plotter() pl.plot(sphere) pl.show(dark_mode=True) + + +def test_plotter_show_mix(): + """Test mixing plot and show methods.""" + pl = Plotter() + sphere = pv.Sphere() + sphere1 = pv.Sphere(center=(0, 0, 1)) + # Plot + pl.plot(sphere1, opacity=0.5, color="blue") + + # Mix plot and show + pl.show(sphere, plotting_options={"show_edges": True}, cpos="xy")