ggbiplot: Biplot for Principal Components using ggplot2

View source: R/ggbiplot.R

ggbiplotR Documentation

Biplot for Principal Components using ggplot2

Description

Renders a custom publication-ready biplot for PCA models created via prcomp(), princomp(), FactoMineR::PCA(), or MASS::lda().

Usage

ggbiplot(
  pcobj,
  choices = 1:2,
  scale = 1,
  pc.biplot = TRUE,
  obs.scale = 1 - scale,
  var.scale = scale,
  groups = NULL,
  ellipse = FALSE,
  ellipse.prob = 0.68,
  labels = NULL,
  labels.size = 3,
  alpha = 1,
  var.axes = TRUE,
  circle = FALSE,
  circle.prob = 0.69,
  varname.size = 3,
  varname.adjust = 1.5,
  varname.abbrev = FALSE,
  ...
)

Arguments

pcobj

Object. A PCA object returned by prcomp, princomp, or PCA().

choices

Numeric vector of length 2. Indices of principal components to plot. Default c(1, 2).

scale

Numeric. Scale factor (0 or 1). Covariance biplot (scale = 1), form biplot (scale = 0). Default 1.

pc.biplot

Logical. If TRUE, ensures compatibility with biplot.princomp() scaling. Default TRUE.

obs.scale

Numeric. Scale factor applied to observations. Default 1 - scale.

var.scale

Numeric. Scale factor applied to variables. Default scale.

groups

Factor. Optional grouping variable to color-code observations. Default NULL.

ellipse

Logical. If TRUE, draws a normal concentration ellipse for each group. Default FALSE.

ellipse.prob

Numeric. Probability level for concentration ellipse size. Default 0.68.

labels

Character vector. Optional custom labels for observations. Default NULL.

labels.size

Numeric. Text size used for observation labels. Default 3.

alpha

Numeric [0, 1]. Transparency for points. Default 1.

var.axes

Logical. If TRUE, renders variable loading arrows. Default TRUE.

circle

Logical. If TRUE, draws a correlation circle. Default FALSE.

circle.prob

Numeric. Size of the correlation circle in Normal probability. Default 0.69.

varname.size

Numeric. Text size for variable names. Default 3.

varname.adjust

Numeric. Adjustment factor for variable name placement (\ge 1 moves text away from arrow). Default 1.5.

varname.abbrev

Logical. If TRUE, abbreviates variable names. Default FALSE.

...

Additional arguments passed to ggplot2.

Value

A ggplot object.


OceanTracer documentation built on Oct. 15, 2026, 5:09 p.m.