Changelog
Source:NEWS.md
betterbiplot 2.0.1
Changes & Improvements
- Moved
title.legintoleg.args = list(title = ...)(top-leveltitle.legremains accepted with a deprecation warning). - Reorganised
R/source files (R/bb_biplot.R,R/methods.R,R/utils.R) and simplified S3 methods to usepcdirectly. - Removed the
methodsimport by replacinghasArg()with explicit!missing(...) && !is.null(...)checks. - Updated
bb_biplot.principal()to use rotated variance proportions fromVaccounted["Proportion Var", ]when available. - Updated GitHub Actions workflows to
actions/checkout@v6(Node.js 24) and moved README SVG figures intoman/figures/so they display on thepkgdownsite.
Bug Fixes
-
Varimax rotation consistency: Fixed
varimax.rotate = TRUEto rotate both observation scores and variable loadings consistently (beforescale/pc.biplotscaling), preserving inner products and updating axis%variance labels. -
autolimellipse limit expansion: Fixed the limit multiplier (ceiling((ecm / max(lim)) * 10) / 10) so large ellipses (such as small-sample Hotelling’s T-squared ellipses) are no longer clipped. -
Convex hulls and ellipses on
data.frameandNAinputs: Indexedxdirectly byas.integer(group)and filtered non-finite coordinates, fixing silent failures whenxis adata.frameand crashes whenxorgroupcontainsNA. -
labdwithpos = "auto"andNAcoordinates: Added a fallback forNApositions sotext()no longer throwsinvalid 'pos' value. -
Ungrouped
group_colsand vectorcolwithpch = 21: Returned the fill colour (colf) rather than"black"inres$group_colswhen ungrouped, and applied black outlines consistently across all observations when passing per-observationcolwithpch = 21:25. -
Zero-variance PCs: Guarded against division by zero in
.bb_scale_pca(),bb_biplot.PCA(),bb_biplot.pca(), andpvarso collinear/zero-variance components no longer produceNaN/Inf. -
Input validation & explicit
NULLarguments: Validatedpcas positive integers and handled explicitNULLoptional arguments cleanly as omitted.
betterbiplot 2.0.0
Package Conversion
- Converted the standalone
r/better_biplot.rscript into thebetterbiplotR package with properDESCRIPTION,NAMESPACE, roxygen2 documentation (?bb_biplot), andtestthatunit tests. - Retained a stub
r/better_biplot.r(excluded from package builds via.Rbuildignore) that prints a migration notice whensource()d directly from GitHub. - Updated
README.mdwith package installation instructions (remotes::install_github("benbell95/better_biplot")) and fixed minor argument typos (group3,f1.a).
New Features
-
Added S3 methods for additional PCA objects without adding hard dependencies:
-
bb_biplot.rda()for unconstrainedvegan::rda()PCA models (converted to base Rscalefor full compatibility withprcomp()/biplot()). -
bb_biplot.svyprcomp()forsurvey::svyprcomp()objects, supportinggroup3 = "scaled"to scale point sizes by survey weights (sqrt(w / max(w))). -
bb_biplot.PCA()forFactoMineR::PCA()objects. -
bb_biplot.pca()forade4::dudi.pca()objects. -
bb_biplot.principal()forpsych::principal()objects.
-
Added selective group legends:
legendnow acceptsTRUE/"all"(all supplied groups) or integer values in1:3(e.g.1,c(1, 3),3) to display only selected group legends, with positional or group-indexedtitle.legmatching.Condensed
group3legends to always show minimum, middle, and maximum symbol sizes (withy.intersp = 1.25), and wiredsurvey::svyprcomp(..., group3 = "scaled")to also display a condensed min/median/max weight legend when legends are enabled.Streamlined
bb_biplot()arguments by grouping fine-grained styling intolab.args,var.args,ellipse.args(also accepted via aliaschull.args), andleg.args, and combiningpc1/pc2intopc = c(1, 2)(while keepingtitle.legandcircle.eqtop-level).Added a soft deprecation shim for all v1.x flat argument names (
pc1,pc2,col.v,whichv,expand,lab_rotation,angle,se,cex.leg,lpx,f1.a, etc.) so existing scripts continue to run with deprecation warnings.Replaced the v1.x parametric ellipse approximation (
angle,se) with statistical covariance confidence ellipses (ellipse.args = list(method = "cov", level = 0.95), default) and small-sample Hotelling’s T-squared ellipses (method = "t").Added group centroids (
centroids = TRUE,"points", or"labels") and radial spider lines (spider = TRUE).Added
var.args = list(lab.offset = 1.05)to nudge variable labels past arrow tips.Added palette name shorthand in
col(anygrDevices::palette.pals()orgrDevices::hcl.pals()palette, e.g.col = "Okabe-Ito"or"Viridis").Added configurable point opacity (
alpha = 0.85) and hull/ellipse opacity (ellipse.args = list(alpha = 0.25, border.alpha = 0.9)).Made unrotated observation label placement deterministic by default (
lab.args = list(pos = "auto"), also supporting"random"or1:4).bb_biplot()now invisibly returns a"bb_biplot"object (scores,loadings,lim,limr,pc,pvar,group_cols,centroids) for downstream base R annotations.Added
varimax.args(normalize = TRUE,eps = 1e-5) to customisestats::varimax()whenvarimax.rotate = TRUE.Added package vignette
vignette("betterbiplot")with rendered examples across scaling, grouping, overlays, legends,vegan::rda(),survey::svyprcomp(), and post-plot extensions.
Bug Fixes
-
Automatic
xlab/ylabgeneration: Stopped forwarding...intopaste0()(which caused errors when graphical parameters such asmainwere passed) and handled missing/NULLxsdcleanly instead of producing empty labels. -
whichvwithlab_rotation = TRUE: Subsetted variable rotation angles (lvsrt) alongsideyso subsetted variable labels receive their own rotation angles instead of the first rows’ angles. -
whichv = "circle.eq":- Explicitly required
circle.eq = TRUEinstead of leavingmatchunassigned (which previously collided withbase::match). - Checked the 2D vector radius
sqrt((y[, 1] * expand)^2 + (y[, 2] * expand)^2) > crinstead of onlyabs(y[, 2]) > cr, keepingwhichv = "circle.eq"consistent whenexpand != 1.
- Explicitly required
-
Single-variable
whichvsubsetting: Usedy[vmatch, , drop = FALSE]to preserve the 2-column matrix structure cleanly. -
Rotated observation labels: Fixed
adj = c(lsrt[i, 2], lsrt[i, 3])(previously passed column 2 twice, ignoringvalignandran_adjvertical alignment). -
f1andf2callbacks: Replacedas.list(args(f1))withlist()whenf1.a/f2.aare omitted, fixing crashes when calling functions that accept...(such asgraphics::grid()). -
group2symbol assignment: Avoided expanding defaultpchforgroupbefore checkinggroup2, ensuring distinct symbols are generated forgroup2even whennlevels(group) >= nlevels(group2). Added length/group validation forgroup2andgroup3. -
Single-level
grouplegends: Handlednlevels(group) == 1when computing vertical legend spacing so subsequentgroup2/group3legends do not receiveNAy-coordinates. - Ellipses and convex hulls edge cases: Handled unused factor levels and constant-x groups cleanly in ellipses and convex hulls.
-
Label rotation edge cases: Avoided
NaNangles at(0, 0)and applied left-side text justification (ad1 = 1) for allx < 0(including the negative x-axis wherey == 0). -
Modern R checks & namespace hygiene: Replaced
class(x) == .../class(x) != ...withis.factor()/is.character(), avoided shadowingbase::c()andbase::match(), and explicitly imported all non-basefunctions (graphics,grDevices,methods,stats).