Project a set of shapes as scatterpoints into an existing morphospace.

proj_shapes(mspace, shapes, density = TRUE, pipe = TRUE, ...)

Arguments

mspace

An "mspace" object.

shapes

Shape data.

density

Logical; whether to add density distribution for points (univariate ordinations only).

pipe

Logical; is the function being included in a pipe?

...

Further arguments passed to graphics::points().

Value

If a plot device with a morphospace is open, shapes fed to shapes are projected into morphospace. If pipe = FALSE

those scores are returned invisibly. If pipe = TRUE the supplied "mspace" object will be modified by appending a $scores slot to $projected and adding some graphical parameters (stored into the $plotinfo slot), and returned invisibly.

Details

The purpose of this function is to maintain morphospace building and sample representation as separated steps, as well as to add flexibility to graphical representation of scatterpoints.

Examples

#load and extract relevant data, packages and information
library(magrittr)
data("wings")
shapes <- wings$shapes
cactus <- wings$data$sex
species <- wings$data$species
template <- wings$template

#generate basic morphospace, add sampled shapes
mspace(shapes, template = template, mag = 0.7, axes = c(1,2)) %>%
  proj_shapes(shapes = shapes)
#> Error in shapes_mat(shapes): object 'data2d' not found

#change colors, symbols, etc for the scatter
mspace(shapes, template = template, mag = 0.7, axes = c(1,2)) %>%
  proj_shapes(shapes = shapes[,,species == "Db"],  col = c("green"),
              pch = c(1,16)[cactus[species == "Db"]]) %>%
  proj_shapes(shapes = shapes[,,species == "Dk"],  col = c("blue"),
              pch = c(1,16)[cactus[species == "Dk"]])
#> Error in shapes_mat(shapes): object 'data2d' not found