Learn R Programming

Momocs (version 1.0.0)

plot2: Plots Principal Component Analysis ala ggplot2

Description

Displays a PCA object with many useful layers in morphometrics, notably morphological space.

Usage

plot2(x, ...)
"plot2"(x, fac = NULL, xax = "PC1", yax = "PC2", points = TRUE, shapes = TRUE, shapes_pos = "full", ellipse = FALSE, ellipseax = FALSE, ellipse_type = "t", ellipse_level = 0.5, stars = FALSE, chull = FALSE, text, text_abbreviatemin = 1, text_size = 5, center = TRUE, legend_position = "bottom", title = substitute(x), return_df = FALSE, ...)

Arguments

x
a PCA object
...
more arguments to be passed to xxx.
fac
(optionnal)
xax
the name of the component to plot on the x-axis, eg "PC1"
yax
the name of the component to plot on the y-axis, eg "PC2"
points
logical whether to draw points
shapes
logical whether to draw shapes
shapes_pos
a position parameter xxx either "axes", "full", "range", "circle", "xy" or a custom data.frame of positions
ellipse
logical whether to draw confidence ellipses
ellipseax
logical whether to draw confidence ellipses axes
ellipse_type
character one of the available type in ggplot2::stat_ellipse
ellipse_level
numeric the confidence level for ellipses
stars
logical whether to draw segments between every point and their group centroid
chull
logical whether to draw convex hull
text
numeric : 1 is for labelling every shape, 2 for group centroids, 3 is for evry shape using group names
text_abbreviatemin
numeric if not missing, the min.length sensu abbreviate
text_size
numeric to adjust the size of labels
center
logical whether to center the plot
legend_position
character for theme(legend.position), either "none", "top", "bottom", "left", "right"
title
character a title for the plot
return_df
logical whether to return ggplot or the data_frames behind

Value

a ggplot object or a list of data.frames :
  • df0
  • df_shp
  • df_ellipseax
  • df_stars
  • df_chull

Details

Detail the df_s. Detail the calculations.

Examples

Run this code
data(bot)
bp <- PCA(efourier(bot, 8))
plot2(bp)
plot2(bp, "type")
plot2(bp, "type", ellipse=TRUE)
# data(bot)

# bot$fac$fake <- factor(rep(letters[1:4], 10))
# bot$fac$fake2 <- c(runif(20), runif(20, 5, 10))
# xx + stat_density2d(aes(fill = ..level..), geom="polygon", alpha=0.1)

Run the code above in your browser using DataLab