| vectorfield | R Documentation |
Draw a vector field to an existing plot.
vectorfield(x, gradient, scale = 1, max.len = 0.1, min.len = 0.001, ...)
x |
a |
gradient |
a |
scale |
a scaling factor for the arrows to be drawn. |
max.len |
the maximum length of the edges of the arrow head. |
min.len |
the minimum length of the edges of the arrow head. |
... |
further graphical parameters to be passed to |
Carmen van Meegen
arrows for drawing arrows between pairs of points.
x <- seq(-2, 2, 0.2)
n <- length(x)
X <- expand.grid(X = x, Y= x)
f <- function(x,y) x * exp(-x^2-y^2)
df <- deriv(~ x * exp(-x^2-y^2), c("x", "y"), function(x, y){})
res <- df(X[, 1], X[,2])
grad <- attr(res, "gradient")
contour(x, x, matrix(res, n, n), asp = 1)
vectorfield(X, grad)
contour(x, x, matrix(res, n, n), asp = 1)
vectorfield(X, grad, col = 4, code = 1, scale = 2)
contour(x, x, matrix(res, n, n), asp = 1)
vectorfield(X, grad, col = 4, lwd = 2, scale = 2)
contour(x, x, matrix(res, n, n), asp = 1)
vectorfield(X, grad, col = 1, angle = 20, scale = 2)
contour(x, x, matrix(res, n, n), asp = 1)
vectorfield(X, grad, col = 4, angle = 20, length = 0.1)
contour(x, x, matrix(res, n, n), asp = 1)
vectorfield(X, grad, col = 4, angle = 20, length = 0.1, scale = 2)
contour(x, x, matrix(res, n, n), asp = 1)
vectorfield(X, grad, col = 3, min.len = 0.1, max.len = 0.15, scale = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.