A set of routines for plotting, highlighting points, or adding fitted surfaces to PCAs.
# S3 method for pca
plot(x, ax = 1, ay = 2, col = 1, title = "", pch = 1, …)
# S3 method for pca
points(x, which, ax = 1, ay = 2, col = 2, pch = 1, cex = 1, …)
# S3 method for pca
plotid(ord, ids = seq(1:nrow(ord$scores)), ax = 1, ay = 2,
col = 1, …)
# S3 method for pca
hilight(ord, overlay, ax = 1, ay = 2, cols=c(2,3,4,5,6,7),
glyph=c(1,3,5), …)
# S3 method for pca
chullord(ord, overlay, ax = 1, ay = 2, cols=c(2,3,4,5,6,7),
ltys = c(1,2,3), …)
# S3 method for pca
surf(ord, var, ax = 1, ay = 2, col = 2, labcex = 0.8,
family = gaussian, thinplate=TRUE, grid=50, gamma=1, …)
varplot.pca(x, dim=length(x$sdev))
an object of class ‘pca’
the dimension to use for the X axis
the dimension to use for the Y axis
a title for the plot
a logical variable to specify points to be highlighted
an object of class ‘pca’
a factor or integer vector to hilight or distinguish
the sequence of color indices to be used
the sequence of glyphs (pch) to be used
the sequence of line types to be used
a variable to be surfaced
controls the link function passed to ‘gam’: one of ‘gaussian’, ‘binomial’, or ‘poisson’
identifier labels for samples. Defaults to 1:n
number of dimensions to include in barplot
color index for points or contours
size of contour interval labels
a logical switch to control using thinplate splines versus independent additive fits
controls the smoothness of the fit from gam
the number of X and Y values used in establishing a grid
plot character: glyph to plot
character expansion factor: size of plotted characters
arguments to pass to the plot function
Function ‘plotid’ returns a vector of row numbers of identified plots.
Function ‘varplot.pca’ produces two plots: (1) the variance accounted for by eigenvector up to the specified number of dimensions (default = all), and (2) the cumulative variance accounted for by dimension.
Function ‘plot’ produces a scatterplot of sample scores for the specified axes, erasing or over-plotting
Functions ‘points’, ‘plotid’, ‘hilight’, ‘chullord’, and ‘surf’ add detail to an existing plot. The axes specified must match the underlying plot exactly.
Function ‘plotid’ identifies and labels samples (optionally with values from a third vector) in the PCA, and requires interaction with the mouse: left button identifies, right button exits.
Function ‘points’ is passed a logical vector to identify a set of samples by color of glyph. It can be used to identify a single set meeting almost any criterion that can be stated as a logical expression.
Function ‘hilight’ is passed a factor vector or integer vector, and identifies factor values by color and glyph. By specifying values for arguments ‘cols’ and ‘glyph’ it is possible to control the sequence of colors and pch glyphs used in the hilight.
Function ‘chullord’ is passed a factor vector or integer vector, and plots a convex hull around all points in each factor class. By specifying values for arguments ‘cols’ and ‘ltys’ it is possible to control the sequence of colors and linetypes of the convex hulls.
Function ‘surf’ calculates and plots fitted surfaces for logical or
quantitative variables. The function employs the gam
function to fit a variable to the ordination coordinates, and to predict the
values at all grid points. The grid is established with the
‘expand.grid’ function, and the grid is then specified in a call to
‘gam.predict’. The predicted values are trimmed to the the convex hull
of the data, and the contours are fit by ‘contour’. The default link
function for fitting the GAMs is ‘gaussian’, suitable for unbounded
continuous variables. For logical variables you should specify ‘family
= binomial’ to get a logistic GAM, and for integer counts you should specify
‘family = poisson’ to get a Poisson GAM.
# NOT RUN {
data(bryceveg)
data(brycesite)
pca.1 <- pca(bryceveg)
plot(pca.1)
points(pca.1,brycesite$elev>8000)
surf(pca.1,brycesite$elev)
# }
# NOT RUN {
plotid(pca.1,ids=row.names(bryceveg))
# }
Run the code above in your browser using DataLab