Skip to content

Commit f09ffd3

Browse files
authored
2kde use hdi_probs by default (#2383)
* make hdi_probs default * add line
1 parent 8e14fc1 commit f09ffd3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

arviz/plots/kdeplot.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def plot_kde(
7272
If True plot the 2D KDE using contours, otherwise plot a smooth 2D KDE.
7373
hdi_probs : list, optional
7474
Plots highest density credibility regions for the provided probabilities for a 2D KDE.
75-
Defaults to matplotlib chosen levels with no fixed probability associated.
75+
Defaults to [0.5, 0.8, 0.94].
7676
fill_last : bool, default False
7777
If True fill the last contour of the 2D KDE plot.
7878
figsize : (float, float), optional
@@ -270,6 +270,9 @@ def plot_kde(
270270
gridsize = (128, 128) if contour else (256, 256)
271271
density, xmin, xmax, ymin, ymax = _fast_kde_2d(values, values2, gridsize=gridsize)
272272

273+
if hdi_probs is None:
274+
hdi_probs = [0.5, 0.8, 0.94]
275+
273276
if hdi_probs is not None:
274277
# Check hdi probs are within bounds (0, 1)
275278
if min(hdi_probs) <= 0 or max(hdi_probs) >= 1:
@@ -289,7 +292,11 @@ def plot_kde(
289292
"Using 'hdi_probs' in favor of 'levels'.",
290293
UserWarning,
291294
)
292-
contour_kwargs["levels"] = contour_level_list
295+
296+
if backend == "bokeh":
297+
contour_kwargs["levels"] = contour_level_list
298+
elif backend == "matplotlib":
299+
contour_kwargs["levels"] = contour_level_list[1:]
293300

294301
contourf_kwargs = _init_kwargs_dict(contourf_kwargs)
295302
if "levels" in contourf_kwargs:

0 commit comments

Comments
 (0)