Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2kde use hdi_probs by default #2383

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions arviz/plots/kdeplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def plot_kde(
If True plot the 2D KDE using contours, otherwise plot a smooth 2D KDE.
hdi_probs : list, optional
Plots highest density credibility regions for the provided probabilities for a 2D KDE.
Defaults to matplotlib chosen levels with no fixed probability associated.
Defaults to [0.5, 0.8, 0.94].
fill_last : bool, default False
If True fill the last contour of the 2D KDE plot.
figsize : (float, float), optional
Expand Down Expand Up @@ -270,6 +270,9 @@ def plot_kde(
gridsize = (128, 128) if contour else (256, 256)
density, xmin, xmax, ymin, ymax = _fast_kde_2d(values, values2, gridsize=gridsize)

if hdi_probs is None:
hdi_probs = [0.5, 0.8, 0.94]

if hdi_probs is not None:
# Check hdi probs are within bounds (0, 1)
if min(hdi_probs) <= 0 or max(hdi_probs) >= 1:
Expand All @@ -289,7 +292,11 @@ def plot_kde(
"Using 'hdi_probs' in favor of 'levels'.",
UserWarning,
)
contour_kwargs["levels"] = contour_level_list

if backend == "bokeh":
contour_kwargs["levels"] = contour_level_list
elif backend == "matplotlib":
contour_kwargs["levels"] = contour_level_list[1:]

contourf_kwargs = _init_kwargs_dict(contourf_kwargs)
if "levels" in contourf_kwargs:
Expand Down