2121# SOFTWARE.
2222"""Provides a wrapper to aid in plotting."""
2323from abc import abstractmethod
24+ from collections .abc import Callable
2425import importlib .util
2526from typing import TYPE_CHECKING , Any , Dict , List , Optional , Union
2627
@@ -405,15 +406,39 @@ def disable_hover(self):
405406 """Disable hover capabilities in the plotter."""
406407 self ._hover_widget .EnabledOff ()
407408
409+ def __extract_kwargs (self , func_name : Callable , input_kwargs : Dict [str , Any ]) -> Dict [str , Any ]:
410+ """Extracts the keyword arguments from a function signature and returns it as dict.
411+
412+ Parameters
413+ ----------
414+ func_name : Callable
415+ Function to extract the keyword arguments from. It should be a callable function
416+ input_kwargs : Dict[str, Any]
417+ Dictionary with the keyword arguments to update the extracted ones.
418+
419+ Returns
420+ -------
421+ Dict[str, Any]
422+ Dictionary with the keyword arguments extracted from the function signature and
423+ updated with the input kwargs.
424+ """
425+ import inspect
426+ signature = inspect .signature (func_name )
427+ kwargs = {}
428+ for k , v in signature .parameters .items ():
429+ # We are ignoring positional arguments, and passing everything as kwarg
430+ if v .default is not inspect .Parameter .empty :
431+ kwargs [k ] = input_kwargs [k ] if k in input_kwargs else v .default
432+ return kwargs
433+
408434 def show (
409435 self ,
410436 plottable_object : Any = None ,
411437 screenshot : Optional [str ] = None ,
412438 view_2d : Dict = None ,
413439 name_filter : str = None ,
414440 dark_mode : bool = False ,
415- plotting_options : Optional [Dict [str , Any ]] = {},
416- ** show_options : Dict [str , Any ],
441+ ** kwargs : Dict [str , Any ],
417442 ) -> List [Any ]:
418443 """Plot and show any PyAnsys object.
419444
@@ -432,18 +457,23 @@ def show(
432457 Regular expression with the desired name or names to include in the plotter.
433458 dark_mode : bool, default: False
434459 Whether to use dark mode for the widgets.
435- plotting_options : dict, default: None
436- Keyword arguments. For allowable keyword arguments, see the
437- :meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method.
438- **show_options : Any
439- Additional keyword arguments for the show method.
460+ **kwargs : Any
461+ Additional keyword arguments for the show or plot method.
440462
441463 Returns
442464 -------
443465 List[Any]
444466 List with the picked bodies in the picked order.
445467
446468 """
469+ plotting_options = self .__extract_kwargs (
470+ self ._pl ._scene .add_mesh ,
471+ kwargs ,
472+ )
473+ show_options = self .__extract_kwargs (
474+ self ._pl .scene .show ,
475+ kwargs ,
476+ )
447477 self .plot (plottable_object , name_filter , ** plotting_options )
448478 if self ._pl .object_to_actors_map :
449479 self ._object_to_actors_map = self ._pl .object_to_actors_map
@@ -479,6 +509,8 @@ def show(
479509 # Update all buttons/widgets
480510 [widget .update () for widget in self ._widgets ]
481511
512+ # Remove screenshot from show options since we pass it manually
513+ show_options .pop ("screenshot" , None )
482514 self .show_plotter (screenshot , ** show_options )
483515
484516 picked_objects_list = []
0 commit comments