| Title: | Bag-and-Whisker Plot |
|---|---|
| Description: | Implementation of the Bag-and-Whisker Plot for bivariate data. Provides a single user-facing function bag_whisker() that wraps the computation and plotting helpers in this package. For more details, please refer to the paper "The Bag-and-Whisker Plot: A New Bagplot for Bivariate Data" by Qin, Gang, Tong and Cui (2025) <doi:10.48550/arXiv.2512.06314>. |
| Authors: | Shenghao Qin [aut, cre] |
| Maintainer: | Shenghao Qin <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-05-13 23:08:35 UTC |
| Source: | https://github.com/cran/BagWhiskerPlot |
Compute and draw a bag-and-whisker plot of bivariate data that highlights outliers under different type-I error controls. This is a thin user-facing wrapper around the internal computation and ggplot2-based plotting helpers in this package.
bag_whisker( x, y, type1 = "unadjusted", q = 0.1, normal_inlier = FALSE, normal_outter = FALSE, asymp_dist_pv = "chisq", center_type = "hdepth", factor = 3, na.rm = FALSE, approx.limit = 300, show.outlier = TRUE, show.whiskers = TRUE, show.looppoints = TRUE, show.bagpoints = TRUE, show.loophull = FALSE, show.baghull = TRUE, create.plot = TRUE, add = FALSE, pch = 1, cex = 0.6, naive_bag = FALSE, dkmethod = 1, precision = 1, n_cores = 1, verbose = FALSE, debug.plots = "no", timing = FALSE, col.loophull = "#aaccff", col.looppoints = "#3355ff", col.baghull = "#D3D3D3", col.bagpoints = "#000088", transparency = FALSE, show.center = TRUE, show.fence_mag_bag = TRUE, ... )bag_whisker( x, y, type1 = "unadjusted", q = 0.1, normal_inlier = FALSE, normal_outter = FALSE, asymp_dist_pv = "chisq", center_type = "hdepth", factor = 3, na.rm = FALSE, approx.limit = 300, show.outlier = TRUE, show.whiskers = TRUE, show.looppoints = TRUE, show.bagpoints = TRUE, show.loophull = FALSE, show.baghull = TRUE, create.plot = TRUE, add = FALSE, pch = 1, cex = 0.6, naive_bag = FALSE, dkmethod = 1, precision = 1, n_cores = 1, verbose = FALSE, debug.plots = "no", timing = FALSE, col.loophull = "#aaccff", col.looppoints = "#3355ff", col.baghull = "#D3D3D3", col.bagpoints = "#000088", transparency = FALSE, show.center = TRUE, show.fence_mag_bag = TRUE, ... )
x, y
|
Numeric vectors giving the coordinates of the bivariate sample.
You can either supply both |
type1 |
Character string specifying the type-I error control used in
the multiple-testing step. One of |
q |
Numeric, the control level for the multiple testing procedure, default |
normal_inlier |
Logical; if |
normal_outter |
Logical; if |
asymp_dist_pv |
Character string; asymptotic distribution used for
p-value calculation, default |
center_type |
Character string; center definition, default |
factor |
Numeric; the factor lambda for |
na.rm |
Logical; if |
approx.limit |
Integer; threshold above which a subsample is used for
approximating the bag-plot computation, default |
show.outlier |
Logical; if |
show.whiskers |
Logical; if |
show.looppoints |
Logical; if |
show.bagpoints |
Logical; if |
show.loophull |
Logical; if |
show.baghull |
Logical; if |
create.plot |
Logical; if |
add |
Logical; if |
pch, cex
|
Graphical parameters forwarded to the plotting method to control point character and expansion. |
naive_bag |
Logical; if |
dkmethod |
Integer in |
precision |
Numeric; controls precision of hull expansion, default |
n_cores |
Integer or NULL. If greater than 1 or NULL, uses a parallel
backend (via |
verbose |
Logical; if |
debug.plots |
Character string; controls generation of additional
diagnostic plots for debugging, default |
timing |
Logical; if |
col.loophull |
Fill colour used for the loop hull. |
col.looppoints |
Point colour used for the loop points. |
col.baghull |
Fill colour used for the bag hull. |
col.bagpoints |
Point colour used for the bag points. |
transparency |
Logical; if |
show.center |
Logical; if |
show.fence_mag_bag |
Logical; if |
... |
Passed on to the S3 method |
This function is the only exported user-facing entry point of the
package. It calls the internal computational engine
compute.bagWhiskerPlot() and then, by default, plots the resulting
object using a ggplot2-based implementation of the S3 method
plot.bagWhiskerPlot().
An object of class "bagWhiskerPlot" containing the bag-plot
decomposition and outlier information. When show = TRUE, the object
is returned invisibly after drawing the plot.
Produce a bag-whisker plot from a bagWhiskerPlot object using
ggplot2. This is the plotting backend used by bag_whisker() to
render the bag, loop, fence, and whisker elements, with optional highlights for
outliers and the center.
## S3 method for class 'bagWhiskerPlot' plot( x, show.outlier = TRUE, show.whiskers = TRUE, show.looppoints = TRUE, show.bagpoints = TRUE, show.loophull = FALSE, show.baghull = TRUE, show.fence_mag_bag = TRUE, add = FALSE, pch = 16, cex = 0.4, verbose = FALSE, col.loophull = "#aaccff", col.looppoints = "#3355ff", col.baghull = "#7799ff", col.bagpoints = "#000088", col.fence_mag_bag = "#CC33CC", transparency = FALSE, show.center = TRUE, whisker.fade = TRUE, whisker.n = 10, whisker.alpha.start = 0.4, whisker.alpha.end = 0, whisker.end.prop = 0.7, main = NULL, ... )## S3 method for class 'bagWhiskerPlot' plot( x, show.outlier = TRUE, show.whiskers = TRUE, show.looppoints = TRUE, show.bagpoints = TRUE, show.loophull = FALSE, show.baghull = TRUE, show.fence_mag_bag = TRUE, add = FALSE, pch = 16, cex = 0.4, verbose = FALSE, col.loophull = "#aaccff", col.looppoints = "#3355ff", col.baghull = "#7799ff", col.bagpoints = "#000088", col.fence_mag_bag = "#CC33CC", transparency = FALSE, show.center = TRUE, whisker.fade = TRUE, whisker.n = 10, whisker.alpha.start = 0.4, whisker.alpha.end = 0, whisker.end.prop = 0.7, main = NULL, ... )
x |
A |
show.outlier |
Logical; if |
show.whiskers |
Logical; if |
show.looppoints |
Logical; if |
show.bagpoints |
Logical; if |
show.loophull |
Logical; if |
show.baghull |
Logical; if |
show.fence_mag_bag |
Logical; if |
add |
Logical; if |
pch |
Plotting character (shape) used for points. |
cex |
Numeric scaling factor for point sizes and (in 2D) whisker line width. |
verbose |
Logical; currently unused, reserved for possible diagnostic messages. |
col.loophull |
Fill color for the loop hull polygon. |
col.looppoints |
Color for loop-region points. |
col.baghull |
Fill color for the bag hull polygon. |
col.bagpoints |
Color for bag-region points. |
col.fence_mag_bag |
Color for the magnified fence polygon. |
transparency |
Logical; if |
show.center |
Logical; if |
whisker.fade |
Logical; if |
whisker.n |
Integer; number of subsegments used per whisker when
|
whisker.alpha.start |
Numeric in |
whisker.alpha.end |
Numeric in |
whisker.end.prop |
Numeric in |
main |
Optional main title for the plot. |
... |
Additional arguments passed on to the underlying ggplot2
scales or base plot. In particular, |
The function is a plot method for bagWhiskerPlot objects and
relies on ggplot2 for rendering.
A ggplot object representing the
bag-whisker plot, returned invisibly. The plot is drawn as a side effect
when add = FALSE or when add = TRUE with an existing
ggplot object.
bag_whisker, bp_build_layers,
ggplot2