Takes a funspace object produced by funspace() or funspaceGAM() and plots the trait probability distribution (TPD) or the map of the response variable (depending of which kind of funspace object is provided) in a functional space.
# S3 method for funspace
plot(
x = NULL,
type = "global",
which.group = NULL,
quant.plot = FALSE,
quant = NULL,
quant.lty = 1,
quant.col = "grey30",
quant.lwd = 1,
quant.labels = TRUE,
colors = NULL,
ncolors = 100,
pnt = FALSE,
pnt.pch = 19,
pnt.cex = 0.5,
pnt.col = "grey80",
arrows = FALSE,
arrows.length = 1,
arrows.head = 0.08,
arrows.col = "black",
arrows.label.col = "black",
arrows.label.pos = 1.1,
arrows.label.cex = 1,
axis.title = TRUE,
axis.title.x = NULL,
axis.title.y = NULL,
axis.title.cex = 1,
axis.title.line = 2,
axis.cex = 1,
globalContour = TRUE,
globalContour.quant = NULL,
globalContour.lwd = 3,
globalContour.lty = 1,
globalContour.col = "grey50",
xlim = NULL,
ylim = NULL,
...
)No return value. This function is called for its side effect: generating plots.
A funspace object produced by funspace() or funspaceGAM().
character indicating whether the plots should represent the global distribution of observations (type = "global"), or be separated by the groups (type = "groups") provided when the funspace object was created. Defaults to "global". In the case of funspace objects based on a TPD function created with the TPD package, only groups are plotted (there is no "global" distribution).
when plotting groups, either a character or a number indicating the name (character) or position (number) of a single group to be plotted individually.
Logical, Default is TRUE. Should contour lines representing quantiles (specified in quant) be plotted?
A vector specifying the quantiles to be plotted (in case quant.plot is set to TRUE. In case a TPD function is plotted, the quantiles represent the quantiles of the trait probability density function (lower quantiles indicate areas with higher probability density). In case a GAM object is plotted, the quantiles of the fitted response variable are plotted. In case a TPD function is plotted, default quantiles are 0.99 (or the selected threshold if it is lower), 0.5 and 0.25. In the GAM alternative, default quantiles are 0.99, 0.5 and 0.25.
type of line to be used to represent quantiles. See lty argument in graphics::par().
Color to be used in the quantile lines. Defaults to "grey30".
Line width to be used in the quantile lines. Defaults to 1.
Logical, Default is TRUE. Should labels be added to quantile lines?
A vector defining the colors of plotted quantiles in the TPD case. Only two colors need to be specified. The first color is automatically assigned to the highest quantile in quantiles (e.g. 0.99), the second color is assigned to the lowest quantile. These colors are then used to automatically generate a gradient from the greatest to the lowest quantile. Any color is admitted. Default is NULL, in which case c("yellow", "red") is used in case a trait probability density function is plotted and to viridis::viridis(5) in the GAM case.
number of colors to include in the color gradients set by colors. Defaults to 100.
Logical, defaults to FALSE. Should data points be added to the functional space?
Numerical. Graphical parameter to select the type of point to be drawn. Default is set to 19. See pch argument in graphics::par()..
Numerical. Graphical parameter to set the size of the points. Default is 0.5. See cex argument in graphics::par().
Graphical parameter to set the points color. Default is "grey80".
Logical, defaults to FALSE. In case the functional space is based on a PCA, should the loadings of the original traits be represented by arrows in the functional space?
Numerical. Graphical parameter to set the length of the arrow (see arrows). Lower values lead to shorter arrows, which can help to make arrows fit within the represented functional space. Defaults to 1.
Numerical. Graphical parameter to set the length of the arrow head (see arrows). Defaults to 0.08.
Graphical parameter to set the arrows color (see arrows). Default is "black".
Graphical parameter to set the color of the arrows labels color. Default is "black".
Numerical. Graphical parameter to set the position of the arrow labels with respect to the arrow heads. Default is 1.1, which draws arrow labels slightly beyond the arrow heads. A value of 1 means drawing labels on top of arrow heads.
Numerical. Graphical parameter to set the size of arrow labels. Defaults to 1.
Logical. Default is TRUE. Should axes titles be plotted?
Character. The title to be plotted in the x axis if axis.title is set to TRUE. If not specified, a default axis title is plotted.
Character. The title to be plotted in the y axis if axis.title is set to TRUE. If not specified, a default axis title is plotted.
Numerical. Graphical parameter to set the size of the axes titles. Default is 1.
Numerical. Graphical parameter to set the on which margin line to plot axes titles. Default is 2.
Numerical. Graphical parameter to set the size of the axes annotation. Default is 1.
Logical, Default is TRUE. Should a contour line representing the global distribution be plotted when type is set to "groups". Adding a global contour lines provides a common reference for all groups and makes comparisons easier.
A vector specifying the quantiles to be plotted (in case globalContour is set to TRUE. Defaults to the threshold selected when the provided funspace object was originally created.
Line width to be used in the global contour lines. Defaults to 3.
type of line to be used to represent the global contour lines. See lty argument in graphics::par(). Defaults to 1 (a continuous line).
Graphical parameter to set the color of the global contour lines. Default is "grey50".
the x limits (x1, x2) of the plot.
the y limits (y1, y2) of the plot.
Other arguments
Produces default plots. If the input object was generated with funspace(), the plot shows a bivariate functional trait space displaying trait probability densities (for single or multiple groups). If the input object was generated with funspaceGAM, the plot shows a heatmap depicting how a target variable is distributed within the functional trait space (for single or multiple groups).
x <- princomp(GSPFF)
funtest <- funspace(x = x, PCs = c(1, 2), threshold = 0.95)
plot(funtest, type = "global", quant.plot = TRUE, quant.lwd = 2, pnt = TRUE, pnt.cex = 0.1,
pnt.col = rgb(0.1, 0.8, 0.2, alpha = 0.2), arrows = TRUE, arrows.length = 0.7)
Run the code above in your browser using DataLab