Skip to content
1 change: 1 addition & 0 deletions doc/changelog.d/306.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feat: improve optional arguments in `show`
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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 <pyvista.Plotter.add_mesh>` method.
**show_options : Any
Additional keyword arguments for the show method.

Returns
-------
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions tests/test_generic_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Loading