Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

vecscale

Scale vectors to fill the current plot


Description

Calculates a scale factor so that a collection of vectors nearly fills the current plot, that is, the longest vector does not extend beyond the plot region.

Usage

vecscale(vectors, bbox = matrix(par("usr"), 2, 2), origin = c(0, 0), factor = 0.95)

Arguments

vectors

a two-column matrix giving the end points of a collection of vectors

bbox

the bounding box of the containing plot region within which the vectors are to be plotted

origin

origin of the vectors

factor

maximum length of the rescaled vectors relative to the maximum possible

Value

scale factor, the multiplier of the vectors

Author(s)

Michael Friendly

See Also

Examples

bbox <- matrix(c(-3, 3, -2, 2), 2, 2)
colnames(bbox) <- c("x","y")
rownames(bbox) <- c("min", "max")
bbox

vecs <- matrix( runif(10, -1, 1), 5, 2)

plot(bbox)
arrows(0, 0, vecs[,1], vecs[,2], angle=10, col="red")
(s <- vecscale(vecs))
arrows(0, 0, s*vecs[,1], s*vecs[,2], angle=10)

candisc

Visualizing Generalized Canonical Discriminant and Canonical Correlation Analysis

v0.8-5
GPL (>= 2)
Authors
Michael Friendly [aut, cre], John Fox [aut]
Initial release
2021-01-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.