diff --git a/preliz/internal/plot_helper.py b/preliz/internal/plot_helper.py index 2953aec2..97c8024a 100644 --- a/preliz/internal/plot_helper.py +++ b/preliz/internal/plot_helper.py @@ -373,6 +373,24 @@ def get_textboxes(signature, model): disabled=False, ) + textboxes["__set_ylim__"] = Checkbox( + value=False, description="set ylim", disabled=False, indent=False + ) + + textboxes["__y_min__"] = FloatText( + value=-10, + step=0.1, + description="y_min", + disabled=False, + ) + + textboxes["__y_max__"] = FloatText( + value=10, + step=0.1, + description="y_max", + disabled=False, + ) + textboxes["__resample__"] = ToggleButton( value=True, description="Resample", diff --git a/preliz/ppls/agnostic.py b/preliz/ppls/agnostic.py index 0c103b3b..b785f354 100644 --- a/preliz/ppls/agnostic.py +++ b/preliz/ppls/agnostic.py @@ -234,6 +234,16 @@ def looper(*args, **kwargs): else: auto = False + y_min = kwargs.pop("__y_min__", None) + y_max = kwargs.pop("__y_max__", None) + set_ylim = kwargs.pop("__set_ylim__", False) + if not set_ylim: + y_min = None + y_max = None + auto_ylim = True + else: + auto_ylim = False + if engine == "preliz": results = [] for _ in range(iterations): @@ -264,6 +274,7 @@ def looper(*args, **kwargs): _, ax = plt.subplots() ax.set_xlim(x_min, x_max, auto=auto) + ax.set_ylim(y_min, y_max, auto=auto_ylim) if plot_func is None: plot_repr(results, kind_plot, references, iterations, ax) else: diff --git a/preliz/predictive/predictive_explorer.py b/preliz/predictive/predictive_explorer.py index c7ace583..5dacd1ca 100644 --- a/preliz/predictive/predictive_explorer.py +++ b/preliz/predictive/predictive_explorer.py @@ -46,7 +46,15 @@ def predictive_explorer( textboxes = get_textboxes(signature, model) new_fmodel = ppl_plot_decorator(fmodel, samples, kind_plot, references, plot_func, engine) out = interactive_output(new_fmodel, textboxes) - default_names = ["__set_xlim__", "__x_min__", "__x_max__", "__resample__"] + default_names = [ + "__set_xlim__", + "__x_min__", + "__x_max__", + "__set_ylim__", + "__y_min__", + "__y_max__", + "__resample__", + ] default_controls = [textboxes[name] for name in default_names] params_controls = [v for k, v in textboxes.items() if k not in default_names]