funct.space.plot {mFD} | R Documentation |
Plot species position in a functional space
Description
This function illustrates the position of species along pairs of axes of a functional space
Usage
funct.space.plot(
sp_faxes_coord,
faxes = NULL,
name_file = NULL,
faxes_nm = NULL,
range_faxes = c(NA, NA),
color_bg = "grey95",
color_pool = "darkturquoise",
fill_pool = "white",
shape_pool = 21,
size_pool = 1,
plot_ch = TRUE,
color_ch = "darkblue",
fill_ch = "white",
alpha_ch = 1,
plot_vertices = TRUE,
color_vert = "darkturquoise",
fill_vert = "darkturquoise",
shape_vert = 22,
size_vert = 1,
plot_sp_nm = NULL,
nm_size = 3,
nm_color = "black",
nm_fontface = "plain",
check_input = TRUE
)
Arguments
sp_faxes_coord |
a matrix of species coordinates in a
multidimensional functional space. Species coordinates have been retrieved
thanks to |
faxes |
a vector with names of axes to plot (as columns names in
|
name_file |
a character string with name of file to save the
figure (without extension). Default: |
faxes_nm |
a vector with axes labels for figure. Default: as
|
range_faxes |
a vector with minimum and maximum values of axes
used for all plots to have a fair representation of position of species.
Default: |
color_bg |
a R color name or an hexadecimal code used to fill plot
background. Default: |
color_pool |
a R color name or an hexadecimal code referring to the
color of symbol for species. Default: |
fill_pool |
a R color name or an hexadecimal code referring to the
color to fill species symbol (if |
shape_pool |
a numeric value referring to the shape of symbol used for
species. Default: |
size_pool |
a numeric value referring to the size of symbol for
species. Default: |
plot_ch |
a logical value indicating whether the convex hull shaping
the pool of species should be illustrated. If |
color_ch |
a R color name or an hexadecimal code referring to the
border of the convex hull filled by the pool of species. Default:
|
fill_ch |
a R color name or an hexadecimal code referring to the
filling of the convex hull filled by the pool of species. Default:
|
alpha_ch |
a numeric value for transparency of the filling of the
convex hull (0 = high transparency, 1 = no transparency). Default:
|
plot_vertices |
a logical value defining whether vertices of the convex
hull shaping the pool of species should be illustrated. If
|
color_vert |
a character value referring to the color of symbol for
vertices if |
fill_vert |
a character value referring to the color for filling symbol
for vertices (if |
shape_vert |
a numeric value referring to the symbol used to show
vertices position if |
size_vert |
a numeric value referring to the size of symbol for
vertices Default: |
plot_sp_nm |
a vector containing species names that are to be printed
near their position. Default: |
nm_size |
a numeric value for size of species label. Default is |
nm_color |
a R color name or an hexadecimal code referring to the color
of species label. Default: |
nm_fontface |
a character string for font of species labels (e.g.
"italic", "bold"). Default: |
check_input |
a logical value indicating whether key features the
inputs are checked (e.g. class and/or mode of objects, names of rows
and/or columns, missing values). If an error is detected, a detailed
message is returned. Default: |
Value
If name_file
is NULL
, a list containing ggplot2
objects is returned: plots of functional space along all pairs of axes
(named according to axes names, e.g. "PC1_PC2"), figure 'caption', and the
full figure 'patchwork' built using the library patchwork
.
If name_file
is not NULL
a 300dpi png file
is saved in the working directory. Ranges of axes are the same for all
panels and if required projection of the convex hull computed in the
multidimensional space provided as input sp_faxes_coord
is
illustrated with a polygon. Species being vertices of this convex hull are
shown with aesthetics provided as inputs ..._vert
. Labels for
species listed in plot_sp_nm
are added with if required arrows
using ggrepel
. Summary about species and dimensionality are printed
on top-right corner of the figure.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:
data("fruits_traits", package = "mFD")
# Load Assemblages*Species dataframe:
data("baskets_fruits_weights", package = "mFD")
# Load Traits categories dataframe:
data("fruits_traits_cat", package = "mFD")
# Compute functional distance
sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits,
tr_cat = fruits_traits_cat,
metric = "gower",
scale_euclid = "scale_center",
ordinal_var = "classic",
weight_type = "equal",
stop_if_NA = TRUE)
# Compute functional spaces quality to retrieve species coordinates matrix:
fspaces_quality_fruits <- mFD::quality.fspaces(
sp_dist = sp_dist_fruits,
maxdim_pcoa = 10,
deviation_weighting = "absolute",
fdist_scaling = FALSE,
fdendro = "average")
# Retrieve species coordinates matrix:
sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord
# Plot functional spaces:
mFD::funct.space.plot(
sp_faxes_coord = sp_faxes_coord_fruits[, c("PC1", "PC2", "PC3", "PC4")],
faxes = NULL,
name_file = NULL,
faxes_nm = NULL,
range_faxes = c(NA, NA),
color_bg = "grey95",
color_pool = "darkturquoise",
fill_pool = "white",
shape_pool = 21,
size_pool = 1,
plot_ch = TRUE,
color_ch = "darkblue",
fill_ch = "white",
alpha_ch = 1,
plot_vertices = TRUE,
color_vert = "darkturquoise",
fill_vert = "darkturquoise",
shape_vert = 22,
size_vert = 1,
plot_sp_nm = NULL,
nm_size = 3,
nm_color = "black",
nm_fontface = "plain",
check_input = TRUE)