plotxy | R Documentation |
2-dimension scatter plot.
plotxy(X, asp = 1, col = NULL, alpha.f = .8,
group = NULL, legend = TRUE, legend.title = NULL, ncol = 1,
zeroes = FALSE, circle = FALSE, ellipse = FALSE,
labels = FALSE,
...)
X |
A |
asp |
Scalar. Giving the aspect ratio y/x. The value |
col |
A color, or a vector of colors (of length equal to the number of groups), defining the color(s) of the points. |
alpha.f |
Scalar modifying the opacity of the points in the graphics; typically in [0,1]. See |
group |
A vector of length |
legend |
Only if there are groups. Logical indicationg is a legend is drawn for groups (Default to |
legend.title |
Character string indicationg a title for the legend. |
ncol |
Number of columns drawn in the legend box. |
zeroes |
Logical indicationg if an horizontal and vertical lines are drawn at coordonates (0, 0) (Default to |
circle |
Logical indicating if a correlation circle (see examples in |
ellipse |
Logical indicating if a Gaussian ellipse is plotted (default to |
labels |
Logical indicating if the row names of |
... |
Other arguments to pass in functions |
A plot.
data(datcass)
Xr <- datcass$Xr
yr <- datcass$yr
Xu <- datcass$Xu
yu <- datcass$yu
ncomp <- 5
fm <- pca(Xr, Xu, ncomp = ncomp)
names(fm)
Tr <- fm$Tr
Tu <- fm$Tu
cor.circle <- fm$cor.circle
coord.var <- fm$coord.var
headm(Tr)
headm(Tu)
oldpar <- par(mfrow = c(1, 1))
par(mfrow = c(1, 2))
plotxy(Tr[, 1:2])
plotxy(Tr[, 3:4], pch = 16, ellipse = TRUE)
par(oldpar)
T <- rbind(Tr, Tu)
group <- c(rep("Reference", nrow(Tr)), rep("Unknown", nrow(Tu)))
oldpar <- par(mfrow = c(1, 1))
par(mfrow = c(1, 2))
plotxy(T, group = group, pch = 16, ellipse = TRUE)
plotxy(T[, 3:4], group = group, pch = 16)
par(oldpar)
### See: ?hcl.colors, hcl.pals()
group <- 1:nrow(Tr)
col <- hcl.colors(n = length(group), alpha = .5, rev = FALSE, palette = "Blues")
plotxy(Tr, group = group, col = col, legend = FALSE, pch = 16)
############## FICTIVE PCA EXAMPLE
n <- 10 ; p <- 6
set.seed(1)
X <- matrix(rnorm(n * p, mean = 10), ncol = p, byrow = TRUE)
set.seed(NULL)
Xr <- X[1:8, ]
Xu <- X[9:10, ]
fm <- pca(Xr, Xu, ncomp = ncomp)
Tr <- fm$Tr
Tu <- fm$Tu
P <- fm$P
T <- rbind(Tr, Tu)
row.names(T) <- 1:nrow(T)
group <- c(rep("Reference", nrow(Tr)), rep("Unknown", nrow(Tu)))
plotxy(T, group = group, pch = 16, zeroes = TRUE)
plotxy(T, group = group, labels = TRUE, zeroes = TRUE)
plotxy(P, zeroes = TRUE, labels = TRUE)
plotxy(fm$coord.var, zeroes = TRUE, labels = TRUE)
plotxy(fm$cor.circle, zeroes = TRUE, labels = TRUE, circle = TRUE, ylim = c(-1, 1))
############## EXTERNAL RESIZED WINDOW
Xr <- datcass$Xr
fm <- pca(Xr, ncomp = 4)
## Do as below (removing comments '#'):
#windows(width = 7, height = 6)
#plotxy(Tr)
#dev.off()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.