Skip to content

Commit

Permalink
Rename fixed_lim to xy_lim (#245)
Browse files Browse the repository at this point in the history
* Rename fixed_lim to xy_lim

* Fix typo
  • Loading branch information
aleicazatti authored May 9, 2023
1 parent fb7828d commit bf064e6
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions preliz/distributions/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Parent classes for all families.
"""
# pylint: disable=no-member
import warnings
from collections import namedtuple

from ipywidgets import interactive
Expand Down Expand Up @@ -399,11 +400,12 @@ def plot_ppf(
def plot_interactive(
self,
kind="pdf",
fixed_lim="both",
xy_lim="both",
pointinterval=True,
interval="hdi",
levels=None,
figsize=None,
fixed_lim=None,
):
"""
Interactive exploration of distributions parameters
Expand All @@ -412,12 +414,12 @@ def plot_interactive(
----------
kind : str:
Type of plot. Available options are `pdf`, `cdf` and `ppf`.
fixed_lim : str or tuple
xy_lim : str or tuple
Set the limits of the x-axis and/or y-axis.
Defaults to `"both"`, the limits of both axis are fixed.
Use `"auto"` for automatic rescaling of x-axis and y-axis.
Or set them manually by passing a tuple of 4 elements,
the first two fox x-axis, the last two for x-axis. The tuple can have `None`.
the first two for x-axis, the last two for x-axis. The tuple can have `None`.
pointinterval : bool
Whether to include a plot of the quantiles. Defaults to False. If True the default is to
plot the median and two interquantiles ranges.
Expand All @@ -440,7 +442,14 @@ def plot_interactive(

self.__init__(**args)

if fixed_lim == "both":
if fixed_lim is not None:
warnings.warn(
"The 'fixed_lim' parameter will be deprecated. Use 'xy_lim' instead.",
FutureWarning,
)
xy_lim = fixed_lim

if xy_lim == "both":
xlim = self._finite_endpoints("full")
xvals = self.xvals("restricted")
if kind == "pdf":
Expand All @@ -449,9 +458,9 @@ def plot_interactive(
elif kind == "ppf":
max_ppf = self.ppf(0.999)
ylim = (-max_ppf * 0.075, max_ppf * 1.5)
elif isinstance(fixed_lim, tuple):
xlim = fixed_lim[:2]
ylim = fixed_lim[2:]
elif isinstance(xy_lim, tuple):
xlim = xy_lim[:2]
ylim = xy_lim[2:]

sliders = {}
if self.__class__.__name__ == "Categorical":
Expand Down Expand Up @@ -498,9 +507,9 @@ def plot(**args): # pylint: disable=inconsistent-return-statements
levels=levels,
figsize=figsize,
)
if fixed_lim != "auto" and kind != "ppf":
if xy_lim != "auto" and kind != "ppf":
ax.set_xlim(*xlim)
if fixed_lim != "auto" and kind != "cdf":
if xy_lim != "auto" and kind != "cdf":
ax.set_ylim(*ylim)

return interactive(plot, **sliders)
Expand Down

0 comments on commit bf064e6

Please sign in to comment.