| vectors | R Documentation |
Graphics utility functions to draw vectors from an origin to a collection of
points (using graphics::arrows() in 2D or
rgl::lines3d() in 3D) with labels for each (using graphics::text()
or rgl::texts3d()
vectors(
x,
origin = c(0, 0),
labels = rownames(x),
scale = 1,
col = "blue",
lwd = 1,
cex = 1,
length = 0.1,
angle = 13,
pos = NULL,
...
)
x |
A two-column matrix or a three-column matrix containing the end points of the vectors |
origin |
Starting point(s) for the vectors |
labels |
Labels for the vectors |
scale |
A multiplier for the length of each vector |
col |
color(s) for the vectors. |
lwd |
line width(s) for the vectors. |
cex |
color(s) for the vectors. |
length |
For |
angle |
For |
pos |
For |
... |
other graphical parameters, such as |
The graphical parameters col, lty and lwd can be
vectors of length > 1 and will be recycled if necessary across the rows of x which define the vectors.
For use in high-level plots, vecscale() can be used to find a value for the scale argument to automatically re-scale
the vectors to approximately fill the plot region.
The option xpd = TRUE can be passed to vectors() via the ... argument to avoid labels being clipped.
None
Michael Friendly
graphics::arrows(), graphics::text(), graphics::segments()
[rgl::lines3d()], [rgl::texts3d()]
set.seed(1234)
plot(c(-3, 3), c(-3,3), type="n",
xlab = "X", ylab = "Y")
X <- matrix(rnorm(10), ncol=2)
rownames(X) <- LETTERS[1:5]
vectors(X, scale=2, col=palette(), xpd = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.