Skip to content

Add unified wrapper functions for plot families#438

Open
ishaan-arora-1 wants to merge 1 commit intostan-dev:masterfrom
ishaan-arora-1:feature/unified-wrapper-functions-433
Open

Add unified wrapper functions for plot families#438
ishaan-arora-1 wants to merge 1 commit intostan-dev:masterfrom
ishaan-arora-1:feature/unified-wrapper-functions-433

Conversation

@ishaan-arora-1
Copy link
Contributor

Fixes #433

This adds high-level wrapper functions that let users access each plot family through a single function + type argument, instead of needing to know the exact function name upfront.

New wrappers

PPC: ppc_error(), ppc_dist(), ppc_discrete(), ppc_loo()
PPD: ppd_dist()
MCMC: mcmc_dist(), mcmc_trace_w(), mcmc_diag(), mcmc_nuts(), mcmc_recover()

For example, instead of remembering ppc_dens_overlay() vs ppc_ecdf_overlay() vs ppc_hist(), users can call:

ppc_dist(y, yrep, type = "dens_overlay")
ppc_dist(y, yrep, type = "hist")
ppc_dist(y, yrep, type = "ecdf_overlay", grouped = TRUE, group = g)

Partial matching on type is supported. Families with _grouped variants accept grouped = TRUE. All other arguments are forwarded via ....

The underlying functions remain fully available — these wrappers are thin dispatchers that just make the API a bit more discoverable.

What's included

  • R/wrappers.R — all wrapper implementations with a shared .dispatch() helper
  • man/bayesplot-wrappers.Rd — consolidated docs listing valid types per family
  • tests/testthat/test-wrappers.R — tests covering dispatch, grouped variants, error cases, and partial matching
  • NEWS.md and NAMESPACE updated

Introduce high-level wrapper functions that consolidate related plotting
functions into single entry points with a `type` argument:

- ppc_error(), ppc_dist(), ppc_discrete(), ppc_loo()
- ppd_dist()
- mcmc_dist(), mcmc_trace_w(), mcmc_diag(), mcmc_nuts(), mcmc_recover()

Each wrapper dispatches to the underlying function (e.g.,
ppc_dist(type = "hist") calls ppc_hist()). Wrappers that have grouped
variants accept a `grouped` flag.

Fixes stan-dev#433
@jgabry
Copy link
Member

jgabry commented Mar 10, 2026

Let's wait on this until we've had a chance to discuss in #433

@jgabry
Copy link
Member

jgabry commented Mar 10, 2026

In general for things like this that require discussion we should wait to open PRs until we've had the discussion and agreed on the new design. For things like fixing deprecations or fixing documentation (or other things like that that don't require discussion) it's ok to just open the PR.

@ishaan-arora-1
Copy link
Contributor Author

In general for things like this that require discussion we should wait to open PRs until we've had the discussion and agreed on the new design. For things like fixing deprecations or fixing documentation (or other things like that that don't require discussion) it's ok to just open the PR.

Alright, thankyou for the feedback!! Will keep in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unified wrapper functions for bayesplot families

2 participants