translation | R Documentation |
Compute a translation for a set of points. The transformed set of points is optionally add to the current plot.
translation(x, y, xtrans = 0, ytrans = 0, add = FALSE, ...)
x, y |
x and y coordinates of points to be translated (can also be a matrix, see details). |
xtrans, ytrans |
the x and y coordinates of the translation vector. |
add |
logical. If |
... |
Additional arguments to be passed to |
For details about what is a translation, see
https://en.wikipedia.org/wiki/Translation_(geometry). Note that if x
is
a matrix with more than 2 columns, then x is the first column and y the
second one.
# Example 1: plot0(c(0,10),c(0,10)) x <- c(4,6,5) y <- c(2,2,4) polygon(x,y) trans1 <- translation(x,y,xtrans=2,ytrans=5, add=TRUE, border=4, lwd=2) # Example 2: x <- c(2,4,3,1) y <- c(1,1,3,3) plot0(c(0,10),c(0,10)) polygon(x,y) for (i in seq_len(6)) translation(x,y,xtrans=i,ytrans=i, add=TRUE, border=i+1, lwd=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.