procrustes.var.plot: Plot Procrustes variation

View source: R/procrustes.var.plot.R

procrustes.var.plotR Documentation

Plot Procrustes variation

Description

Modification of the plotRefToTarget function to allow to display landmark variation on Procrustes

Usage

procrustes.var.plot(
  M1,
  M2,
  col = list("grey", "black"),
  col.val,
  magnitude = 1,
  labels = FALSE,
  axes = FALSE,
  pt.size = 1,
  gridPar,
  col.range,
  lwd = 2,
  ...
)

Arguments

M1

Matrix of landmark coordinates for the first (reference) specimen

M2

Matrix of landmark coordinates for the second (target) specimen

col

Either a single color value ("character"), vector of values or function for colouring both points and vectors; or a list of two of any of these three elements. The first argument is passed to the points and the second to the vectors (default = list("grey", "black") for grey points and black vectors - see details).

col.val

Optional, if col is a function for assigning colours (or a list of two functions), which values to pass to the function to assign the colors).

magnitude

The magnitude of difference between the two shapes (default = 1).

labels

Logical, whether to plot the landmark labels (TRUE) or not (FALSE - default).

axes

Logical, whether to plot the plot axes (TRUE) or not (FALSE - default).

pt.size

The size of the points (default = 1).

gridPar

Optional, a named list of grid parameters generated by gridPar.

col.range

Optional, two numeric values for designating the minimum and maximum range to sample the colors from (see details). If left empty (default), the range of col.val is used.

lwd

Optional, the line width (by default, lwd = 2)

...

Additional parameters to plot or plot3d.

Details

col arguments are passed to plot or plot3d as follows:

  • if col is a single value or a single vector, it passes it to both points and colors arguments;

  • if col is a single function, it applies it to both points and colors arguments based on the argument col.val;

  • if col is a list of two values, vectors or functions, it will apply the first element to the points and the second to the vectors the same way as described above;

If col.val is provided the function samples colors according the the col argument (see above) using the range of the col.val vector. You can change this range to some absolute values by using the col.range option: the colors are then sampled along the col.range range for each col.val.

Author(s)

Thomas Guillerme - original function by Dean Adams, Emma Sherratt & Michael Collyer.

See Also

variation.range

Examples

## Loading the geomorph dataset
require(geomorph)
data(plethodon)

## Performing the Procrustes superimposition
proc_super <- gpagen(plethodon$land, print.progress = FALSE)

## Getting the range of variation
variation <- variation.range(proc_super, return.ID = TRUE)

## Selecting the coordinates and the variation vector
M1 <- proc_super$coords[, , variation$min.max[1]]
M2 <- proc_super$coords[, , variation$min.max[2]]
var_val <- variation$range[, 1]
 
## Plot the variation
procrustes.var.plot(M1, M2)

## A colourful plot
procrustes.var.plot(M1, M2, col = list(grDevices::rainbow, "pink"), col.val = var_val,
                    pt.size = 2.5)

## A series of heat plots with different options
par(mfrow = c(3,1), mar = c(0,0,2,0))
procrustes.var.plot(M1, M2, main = "Uncolored variation")
procrustes.var.plot(M1, M2, col = grDevices::heat.colors, col.val = var_val, 
                    main = "Relative colours")
procrustes.var.plot(M1, M2, col = grDevices::heat.colors, col.val = var_val,
                    col.range = c(0, 0.2), main = "Absolute colours (range = c(0, 0.2))")

## Not run: 
## Loading the scallops 3D data from geomorph
require(geomorph)
data(scallops)

## Procrustes superimposition
procrustes <- gpagen(scallops$coorddata)

## Getting the range of variation
variation <- variation.range(procrustes, return.ID = TRUE)

## Selecting the coordinates and the variation vector
M1 <- procrustes$coords[, , variation$min.max[1]]
M2 <- procrustes$coords[, , variation$min.max[2]]
var_val <- variation$range[, 1]
 
## Plot the variation in 3D
procrustes.var.plot(M1, M2, col.val = var_val, col = list(grDevices::heat.colors, "grey"))

## End(Not run)


TGuillerme/landvR documentation built on July 4, 2025, 10:16 p.m.