| gg.shape.space | R Documentation | 
Make pretty plots from geometric morphometric ordinations
using the output of gm.prcomp (Adams et al. 2020).
gg.shape.space( x, axis1 = 1, axis2 = 2, main.title = NULL, group = NULL, group.title = NULL, convex.hulls = FALSE, label.groups = TRUE, labels = NULL, include.legend = FALSE, fixed.aspect = FALSE, xlim = NULL, ylim = NULL, color = NULL, pt.size = 1.5, pt.alpha = 0.85, hull.alpha = 0.2, save.as = NULL, height = 5, width = 7, scale = 1, units = "in", backtransform.examples = FALSE, shape.method = "points", lm.labels = TRUE, ref.shape = NULL, bt.links = NULL, bt.shape.mag = 1, bt.inset.size = 0.35, bt.margin.factor = 2, bt.legend.position = c(1, 1), ref.pt.size = 1, target.pt.size = 0.75, viridis.color.option = "viridis", group.label.size = 2.5, point.label.size = 2.5 )
| x | An object of class  | 
| axis1 | The PC axis to plot on the horizontal. | 
| axis2 | The PC axis to plot on the vertical. | 
| main.title | An optional title for the plot. | 
| group | A factor to group samples. | 
| group.title | An optional title for the group legend. | 
| convex.hulls | A logical factor specifying whether to plot convex hulls around groups. | 
| label.groups | A logical factor specifying whether to label groups. | 
| labels | An optional character vector of point labels. | 
| include.legend | A logical factor specifying whether to include a legend. | 
| fixed.aspect | A logical factor specifying whether to use a fixed aspect ratio. | 
| xlim | Set x scale limits | 
| ylim | Set y scale limits | 
| color | The color of points and hulls in each group. | 
| pt.size | The size of individual points. | 
| pt.alpha | The opacity of individual points. | 
| hull.alpha | The opacity of the convex hulls. | 
| save.as | An optional filename to export the plot. | 
| height | The height of the exported plot. | 
| width | The width of the exported plot. | 
| scale | A scale factor for elements of the exported plot. | 
| units | The units for height and width of the exported plot. | 
| backtransform.examples | A logical factor specifying whether to include example shapes at the extremes of each axis. | 
| shape.method | Method used to visualize shape differences, following  | 
| lm.labels | A logical factor specifying whether to label landmarks in the example shapes. | 
| ref.shape | A reference of consensus shape. | 
| bt.links | A matrix with two columns indicating landmarks to connect by lines in the example shapes. | 
| bt.shape.mag | The desired magnification to be used on the example shape, in comparison to the reference. | 
| bt.inset.size | The relative size of the example shape insets. | 
| bt.margin.factor | A factor to control size of the margin where example shapes are plotted. | 
| bt.legend.position | A two-element vector specifying the justification and position of the legend in a back-transform plot. | 
| ref.pt.size | Scale factor for reference configuration points (single value or vector of values) | 
| target.pt.size | Scale factor for target configuration points (single value or vector of values) | 
| viridis.color.option | The color pallette to use from the  | 
| group.label.size | Font size for group labels. | 
| point.label.size | Font size for individual point labels. | 
Beware that right now, the save.as feature only works with
backtransform.examples = FALSE.
Dave Angelini david.r.angelini@gmail.com [aut, cre]
Geomorph: Software for geometric morphometric analyses. R package version 3.2.1. D.C. Adams and M.L. Collyer and A. Kaliontzopoulou. 2020. (Link)
library(geomorph)
data(plethodon)
# GPA
Y.gpa <- gpagen(plethodon$land)
# Create a gm.prcomp object
PCA <- gm.prcomp(Y.gpa$coords)
# Morphospace plots
gg.shape.space(PCA, group = plethodon$species, group.title = 'species')
gg.shape.space(PCA, group = plethodon$species, group.title = 'species', convex.hulls = TRUE)
gg.shape.space(PCA, group = plethodon$species, group.title = 'species', convex.hulls = TRUE,
          axis1 = 1, axis2 = 3)
gg.shape.space(PCA, group = plethodon$species, group.title = 'species', convex.hulls = TRUE,
          viridis.color.option = 'plasma')
gg.shape.space(PCA, group = plethodon$species, group.title = 'species', convex.hulls = TRUE,
          color = c("royalblue","gray40"))
# Labeling points
gg.shape.space(PCA, group = plethodon$species, group.title = 'species', convex.hulls = TRUE,
          labels = plethodon$site,
          group.label.size = 8, point.label.size = 2,
          color = c("royalblue","gray40"))
# Plots with example shapes
gg.shape.space(PCA, group = plethodon$species, group.title = 'species', convex.hulls = TRUE,
          backtransform.examples = TRUE,
          ref.shape = Y.gpa$consensus)
# Custom links on the example shapes
pletho.links <- matrix(c(4,5,5,6,6,7,7,8,8,9,9,10,10,11,2,4,12,2,3,5),
                       ncol = 2, byrow = TRUE)
gg.shape.space(PCA, group = plethodon$species, group.title = 'species', convex.hulls = TRUE,
          backtransform.examples = TRUE,
          ref.shape = Y.gpa$consensus,
          bt.links = pletho.links)
# No links on the example shapes
gg.shape.space(PCA, group = plethodon$species, group.title = 'species', convex.hulls = TRUE,
          backtransform.examples = TRUE,
          ref.shape = Y.gpa$consensus,
          bt.links = "none")
# Example shapes displaysed as thin-plate spline (TPS) warp grids
gg.shape.space(PCA, group = plethodon$species, group.title = 'species', convex.hulls = TRUE,
          backtransform.examples = TRUE,
          ref.shape = Y.gpa$consensus,
          shape.method = "TPS",
          lm.labels = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.