Plot confidence ellipses for different groups in 2D scatterplots created using the generic graphics::plot() function. Used internally (mostly).

ellipses_by_group_2D(
  xy,
  fac,
  col = seq_len(nlevels(fac)),
  lty = 1,
  conflev = 0.95,
  alpha = 0,
  ...
)

Arguments

xy

Coordinates of the scatterplot.

fac

A factor grouping data points.

col

A vector (either character or numeric) indicating the colors used for each group.

lty

A numeric vector indicating the type of line used to draw ellipses.

conflev

Numeric, specifying the confidence level for drawing ellipses.

alpha

Numeric; transparency factor for ellipses.

...

Further arguments passed to graphics::polygon().

Examples

#load landmark data and necessary packages
library(geomorph)
data("wings")
shapes <- wings$shapes
species <- wings$data$species

#perform PCA
pca <- prcomp(two.d.array(shapes))

#plot and add 95% confidence ellipses
plot(pca$x)
ellipses_by_group_2D(pca$x, fac = species, col = "black", conflev = 0.95)