plot.cca | R Documentation |
Functions to plot or extract results of constrained correspondence analysis
(cca
), redundancy analysis (rda
), distance-based
redundancy analysis (dbrda
) or
constrained analysis of principal coordinates (capscale
).
## S3 method for class 'cca'
plot(x, choices = c(1, 2), display = c("sp", "wa", "cn"),
scaling = "species", type, xlim, ylim, const,
correlation = FALSE, hill = FALSE, cex = 0.7, ...)
## S3 method for class 'cca'
text(x, display = "sites", labels, choices = c(1, 2),
scaling = "species", arrow.mul, head.arrow = 0.05, select, const,
axis.bp = FALSE, correlation = FALSE, hill = FALSE, ...)
## S3 method for class 'cca'
points(x, display = "sites", choices = c(1, 2),
scaling = "species", arrow.mul, head.arrow = 0.05, select, const,
axis.bp = FALSE, correlation = FALSE, hill = FALSE, ...)
## S3 method for class 'cca'
scores(x, choices = c(1,2), display = "all",
scaling = "species", hill = FALSE, tidy = FALSE, droplist = TRUE,
...)
## S3 method for class 'rda'
scores(x, choices = c(1,2), display = "all",
scaling = "species", const, correlation = FALSE, tidy = FALSE,
droplist = TRUE, ...)
## S3 method for class 'cca'
summary(object, scaling = "species", axes = 6,
display=c("sp","wa","lc","bp","cn"),
digits = max(3, getOption("digits") - 3),
correlation = FALSE, hill = FALSE, ...)
## S3 method for class 'cca'
labels(object, display, ...)
x , object |
A |
choices |
Axes shown. |
display |
Scores shown. These must include some of the
alternatives |
scaling |
Scaling for species and site scores. Either species
( The type of scores can also be specified as one of |
correlation , hill |
logical; if |
tidy |
Return scores that are compatible with
ggplot2: all scores are in a single |
type |
Type of plot: partial match to |
xlim , ylim |
the x and y limits (min,max) of the plot. |
labels |
Optional text to be used instead of row names. If you
use this, it is good to check the default labels and their order
using |
arrow.mul |
Factor to expand arrows in the graph. Arrows will be scaled automatically to fit the graph if this is missing. |
head.arrow |
Default length of arrow heads. |
select |
Items to be displayed. This can either be a logical
vector which is |
const |
General scaling constant to |
droplist |
Return a matrix instead of a named list when only one kind of scores were requested. |
axis.bp |
Draw |
axes |
Number of axes in summaries. |
digits |
Number of digits in output. |
cex |
Character expansion. |
... |
Parameters passed to other functions. |
Same plot
function will be used for cca
and
rda
. This produces a quick, standard plot with current
scaling
.
The plot
function sets colours (col
), plotting
characters (pch
) and character sizes (cex
) to
certain standard values. For a fuller control of produced plot, it is
best to call plot
with type="none"
first, and then add
each plotting item separately using text.cca
or
points.cca
functions. These use the default settings of standard
text
and points
functions and accept all
their parameters, allowing a full user control of produced plots.
Environmental variables receive a special treatment. With
display="bp"
, arrows will be drawn. These are labelled with
text
and unlabelled with points
. The arrows have
basically unit scaling, but if sites were scaled (scaling
"sites"
or "symmetric"
), the scores of requested axes
are adjusted relative to the axis with highest eigenvalue. With
scaling = "species"
or scaling = "none"
, the arrows will
be consistent with vectors fitted to linear combination scores
(display = "lc"
in function envfit
), but with
other scaling alternatives they will differ. The basic plot
function uses a simple heuristics for adjusting the unit-length arrows
to the current plot area, but the user can give the expansion factor
in arrow.mul
. With display="cn"
the centroids of levels
of factor
variables are displayed. With this option continuous
variables still are presented as arrows and ordered factors as arrows
and centroids. With display = "reg"
arrows will be drawn for
regression coefficients (a.k.a. canonical coefficients) of constraints
and conditions. Biplot arrows can be interpreted individually, but
regression coefficients must be interpreted all together: the LC score
for each site is the sum of regressions displayed by arrows. The
partialled out conditions are zero and not shown in biplot arrows, but
they are shown for regressions, and show the effect that must be
partialled out to get the LC scores. The biplot arrows are more
standard and more easily interpreted, and regression arrows should be
used only if you know that you need them.
If you want to have a better control of plots, it is best to
construct the plot text
and points
commands which
accept graphical parameters. It is important to remember to use the
same scaling
, correlation
and hill
arguments
in all calls. The plot.cca
command returns invisibly an
ordiplot
result object, and this will have consistent
scaling for all its elements. The easiest way for full control of
graphics is to first set up the plot frame using plot
with
type = "n"
and all needed scores in display
and save
this result. The points
and text
commands for
ordiplot
will allow full graphical control (see
section Examples). Utility function labels
returns the default
labels in the order they are applied in text
.
Palmer (1993) suggested using linear constraints (“LC scores”)
in ordination diagrams, because these gave better results in
simulations and site scores (“WA scores”) are a step from
constrained to unconstrained analysis. However, McCune (1997) showed
that noisy environmental variables (and all environmental measurements
are noisy) destroy “LC scores” whereas “WA scores” were
little affected. Therefore the plot
function uses site scores
(“WA scores”) as the default. This is consistent with the usage
in statistics and other functions in R (lda
,
cancor
).
The plot
function returns
invisibly a plotting structure which can be used by function
identify.ordiplot
to identify the points or other
functions in the ordiplot
family.
Up to vegan release 2.6-4 summary
printed
ordination scores, and function was occasionally used to extract
scores. This is now deprecated and you should use
scores
. This version of vegan still enables extracting
scores with summary
, but you should change your code to use
scores
before next vegan release. For instructions,
see https://github.com/vegandevs/vegan/discussions/644.
Jari Oksanen
cca
, rda
and capscale
for getting something
to plot, ordiplot
for an alternative plotting routine
and more support functions, and text
,
points
and arrows
for the basic routines.
data(dune)
data(dune.env)
mod <- cca(dune ~ A1 + Moisture + Management, dune.env)
## better control -- remember to set scaling etc identically
plot(mod, type="n", scaling="sites")
text(mod, dis="cn", scaling="sites")
points(mod, pch=21, col="red", bg="yellow", cex=1.2, scaling="sites")
text(mod, "species", col="blue", cex=0.8, scaling="sites")
## catch the invisible result and use ordiplot support - the example
## will make a biplot with arrows for species and correlation scaling
pca <- rda(dune)
pl <- plot(pca, type="n", scaling="sites", correlation=TRUE)
with(dune.env, points(pl, "site", pch=21, col=1, bg=Management))
text(pl, "sp", arrow=TRUE, length=0.05, col=4, cex=0.6, xpd=TRUE)
with(dune.env, legend("bottomleft", levels(Management), pch=21, pt.bg=1:4, bty="n"))
## Scaling can be numeric or more user-friendly names
## e.g. Hill's scaling for (C)CA
scrs <- scores(mod, scaling = "sites", hill = TRUE)
## or correlation-based scores in PCA/RDA
scrs <- scores(rda(dune ~ A1 + Moisture + Management, dune.env),
scaling = "sites", correlation = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.