safeai.rgr.plot_rgr

safeai.rgr.plot_rgr(result, *, model_name='Model', x_key=None, x_label=None, y_key='rgr_rescaled', title=None, fig_size=(12, 6), save_path=None, show=False)[source]

Plot one RGR curve or a comparison of several RGR curves.

Parameters:
  • result (dict) – Either one result returned by rgr_curve(…) or the full dictionary returned by compare_rgr(…).

  • model_name (str, default='Model') – Label used when result is a single curve.

  • x_key (str, optional) – Name of the x-axis field in each result. If None, it is inferred from the result keys, for example ‘noise_levels’ or ‘attack_strengths’.

  • x_label (str, optional) – Human-readable x-axis label. If None, a default label is selected.

  • y_key (str, default='rgr_rescaled') – Name of the y-axis field to plot.

  • title (str, optional) – Plot title. If None, a default title is selected.

  • fig_size (tuple, default=(12, 6)) – Matplotlib figure size.

  • save_path (str or None, default=None) – If provided, save the plot to this path.

  • show (bool, default=False) – If True, display the plot with plt.show().

Returns:

If save_path is provided and show is False, returns save_path. Otherwise, returns (fig, ax).

Return type:

str or tuple