Plot the output from morphogrid(), for 3-dimensional morphometric (landmark) data. Used internally.

plot_morphogrid3d(
  x = NULL,
  y = NULL,
  morphogrid,
  refshape,
  template = NULL,
  links = NULL,
  ordtype,
  axes,
  rotmat = NULL,
  xlim = NULL,
  ylim = NULL,
  xlab = NULL,
  ylab = NULL,
  adj_frame = c(1, 1),
  cex.ldm,
  col.ldm,
  col.models,
  lwd.models,
  size.models,
  alpha.models = 1,
  bg.models,
  asp.models,
  plot = TRUE,
  models = TRUE
)

Arguments

x

Optional vector with a non-morphometric variable to be plotted in the x axis.

y

Optional vector with a non-morphometric variable to be plotted in the y axis.

morphogrid

An object containing the output of morphogrid.

refshape

reference shape (i.e., the mean landmark configuration) corresponding to the mesh provided in template.

template

An optional "mesh3d" object containing geometry of the structure the landmarks were placed on (for 3D shape data), corresponding to the mean shape of the sample, which will be warped using TPS interpolation to produce the set of background shell models.

links

A list with the indices of the coordinates defining the wireframe (following the format used in Morpho).

ordtype

Character; method used for multivariate ordination ("prcomp", "bg_prcomp", "phy_prcomp", "pls_shapes" or "phy_pls_shapes").

axes

Numeric of length 2, indicating the axes to be plotted.

rotmat

Optional rotation matrix for background shape models. If NULL, the user will be asked to define a preferred orientation.

xlim, ylim, xlab, ylab

Standard arguments passed to the generic plot function.

adj_frame

Numeric of length 2, providing a posteriori scaling factors for the width and height of the frame, respectively.

cex.ldm

Numeric; size of landmarks/semilandmarks in the background models.

col.ldm

The color of landmarks/semilandmarks in the background models.

col.models

The color for wireframes/outlines.

lwd.models

Numeric; the width of the lines in wireframes/outlines.

size.models

Numeric; size factor for shape models.

alpha.models

Numeric; transparency factor for background models.

bg.models

Background color for meshes.

asp.models

Numeric; the y/x aspect ratio of shape models.

plot

Logical; whether to plot morphospace.

models

Logical; whether to plot background shape models.

Details

This function allows the user to choose the orientation of the 3D models by interactively rotating a shape model. Do not close the rgl window, or minimize it actively (just bring back Rstudio to the front and let the device get minimized pasively). The process of morphospace generation is rather slow, specially if a mesh is provided for template, a large number of shape models is asked, and/or alpha.models value is lower than 1.

Examples

#load data and packages
library(geomorph)
data("shells3D")
shapes <- shells3D$shapes

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

#generate grid of shape models sampling the range of variation
#at 4 locations (the 4 corners of the scatterplot)
shapes_grid <- morphogrid(ordination = pca, axes = c(1,2), datype = "landm",
                          k = ncol(shapes), p = nrow(shapes),
                          nh = 2, nv = 2)

#get meanshape
meanshape <- expected_shapes(shapes)

if (FALSE) {
#plot grid (shape coordinates only)
plot_morphogrid3d(morphogrid = shapes_grid, refshape = meanshape,
                  ordtype = "prcomp", axes = c(1,2), col.ldm = 1,
                  cex.ldm = 1, col.models = 1, lwd.models = 1,
                  bg.models = "gray", size.models = 2, asp.models = 1)

#get shape corresponding to shells3D$mesh_meanspec using
#geomorph::findMeanSpec, then get mesh corresponding to mean shape using
#Morpho::tps3d
meanspec_id<- findMeanSpec(shapes)
meanspec_shape <- shapes[,,meanspec_id]
meanmesh <- tps3d(x = shells3D$mesh_meanspec , refmat = meanspec_shape,
                  tarmat = meanshape)

#plot grid (includinh mesh template)
plot_morphogrid3d(morphogrid = shapes_grid, template = meanmesh,
                  refshape = meanshape, ordtype = "prcomp", axes = c(1,2),
                  col.ldm = 1, cex.ldm = 1, col.models = 1, lwd.models = 1,
                  bg.models = "gray", size.models = 2, asp.models = 1)
}