Description Usage Arguments Examples
This function will scale a vector in usr coordinates to mm so the plotted length will be as desired. This will be particularly useful in situtations where the plot aspect ratio is unequal to 1.
1 | scale_vec_length_to_mm(v, mm = 10)
|
v |
A 2D vector |
mm |
Numeric. Length to standardize vector to in mm. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | par(mfrow=c(1,2))
plot(NULL, xlim=c(-1,1), ylim=c(-1,1), asp=2,
main="vectors plot length\n varies by direction")
rs <- seq(0, 2*pi, length=41)
v = c(1,0)
for (r in rs) {
R = rotation_matrix_2d(r, clockwise = F)
n = v %*% R
segments(0,0, n[1], n[2])
}
plot(NULL, xlim=c(-1,1), ylim=c(-1,1), asp=2,
main="vectors have 10mm plot\nlength in all directions")
for (r in rs) {
R = rotation_matrix_2d(r, clockwise = F)
n = v %*% R
b = scale_vec_length_to_mm(n, mm=10)
segments(0,0, b[1], b[2])
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.