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

hulls_by_group_2D(
  xy,
  fac,
  col = seq_len(nlevels(fac)),
  lty = 1,
  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 hulls.

alpha

Numeric; transparency factor for hulls.

...

Further arguments passed to graphics::polygon().

Examples

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

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

#plot and add convex hulls
plot(pca$x)
hulls_by_group_2D(pca$x, fac = species, col = "black")