diff --git a/arviz/plots/backends/matplotlib/bpvplot.py b/arviz/plots/backends/matplotlib/bpvplot.py index 3a4e55c7b8..e58ec04e8f 100644 --- a/arviz/plots/backends/matplotlib/bpvplot.py +++ b/arviz/plots/backends/matplotlib/bpvplot.py @@ -38,6 +38,7 @@ def plot_bpv( plot_ref_kwargs, backend_kwargs, show, + smoothing, ): """Matplotlib bpv plot.""" if backend_kwargs is None: @@ -87,7 +88,7 @@ def plot_bpv( obs_vals = obs_vals.flatten() pp_vals = pp_vals.reshape(total_pp_samples, -1) - if obs_vals.dtype.kind == "i" or pp_vals.dtype.kind == "i": + if (obs_vals.dtype.kind == "i" or pp_vals.dtype.kind == "i") and smoothing == True: obs_vals, pp_vals = smooth_data(obs_vals, pp_vals) if kind == "p_value": diff --git a/arviz/plots/bpvplot.py b/arviz/plots/bpvplot.py index f7f869105b..578b19d03f 100644 --- a/arviz/plots/bpvplot.py +++ b/arviz/plots/bpvplot.py @@ -36,6 +36,7 @@ def plot_bpv( backend_kwargs=None, group="posterior", show=None, + smoothing=True, ): r"""Plot Bayesian p-value for observed data and Posterior/Prior predictive. @@ -148,6 +149,8 @@ def plot_bpv( the same comparison happens, but with the values in `prior_predictive` group. show : bool, optional Call backend show function. + smoothing : bool, default True + If True, smooth the data before computing the p-values or u-values. Returns ------- @@ -166,7 +169,7 @@ def plot_bpv( Notes ----- Discrete data is smoothed before computing either p-values or u-values using the - function :func:`~arviz.smooth_data` + function :func:`~arviz.smooth_data` if the data is integer type and the smoothing parameter is True(by default). Examples -------- @@ -291,6 +294,7 @@ def plot_bpv( plot_ref_kwargs=plot_ref_kwargs, backend_kwargs=backend_kwargs, show=show, + smoothing=smoothing, ) # TODO: Add backend kwargs