Plot density distribution for different groups in "univariate" scatterplots. Used internally.

density_by_group_2D(
  xy,
  fac,
  ax,
  alpha = 0.2,
  lwd = 1,
  lty = 1,
  col = seq_len(nlevels(fac))
)

Arguments

xy

Coordinates of the scatterplot.

fac

A factor grouping data points.

ax

the axis of xy corresponding to the active variable.

alpha

Numeric; transparency factor for density distributions.

lwd

A vector indicating the width of line (integer) used to draw density distributions.

lty

A vector indicating the type of line (integer) used to draw density distributions.

col

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

Examples

#load Fourier data and necessary packages
library(geomorph)
data("shells")
shapes <- shells$shapes$coe
species <- shells$data$species

#perform PCA
pca <- prcomp(shapes)

#bind 1st axis with a column of 0s, plot and add density distributions
xy <- cbind(pca$x[,1], 0)
plot(xy, ylim = c(0,1))
density_by_group_2D(xy, fac = species, ax = 1)