to_fig_for

hybrid_learning.experimentation.exp_eval_common.to_fig_for(func, allow_looping=('experiment_root', 'model_key', 'split', 'logic_type'), fig_args=None, shared_legend_in=False, save_overall_fig_as=None, **kwargs)[source]

Apply func to all combinations of elements in the allow_looping list of kwargs-keys and gather results into image. If a value for an allow_looping key is a list or tuple, it will be iterated over. Nested lists get flattened. At each call, the func is supplied with an ax argument holding the axis of the overall figure the function should use. Columns are indexed by values of the first key of allow_looping, rows by combinations of all other looping values.

Parameters
  • func (Callable) – the function to loop over

  • allow_looping – the keys of arguments to loop over in case they are lists or tuples; each column corresponds to a value of the first key

  • fig_args (Optional[Dict[str, Any]]) – fed as keyword arguments to the figure initialization

  • shared_legend_in (Tuple[int, int]) – legends from all axes in the subplots are removed except for the one determined by the (row, col) coordinate in shared_legend_in (if given)

  • save_overall_fig_as (Optional[str]) – file path where to save the final figure

Returns

a tuple of the figure and a list of tuples (used_kwargs, func_return)

Return type

Tuple[Figure, List[Tuple[Dict[str, Any], Any]]]