Learn R Programming

oce (version 0.9-18)

drawDirectionField: Draw a direction field

Description

Draw a direction field

Usage

drawDirectionField(x, y, u, v, scalex, scaley, add=FALSE, type=1,
debug=getOption("oceDebug"), ...)

Arguments

x,y
coordinates at which velocities are specified
u,v
velocity components in the x and y directions
scalex,scaley
scale to be used for the velocity arrows. Exactly one of these must be specified. Arrows that have u^2+v^2=1 will have length scalex along the x axis, or scaley along the y axis, according t
add
if TRUE, the arrows are added to an existing plot; otherwise, a new plot is started, with asp set to 1.
type
type of the arrow-like indication of the direction.
debug
debugging value; set to a positive integer to get debugging information.
...
extra graphical parameters, supplied to functions called by drawDirectionField. Try adjusting cex, pch, and lwd, and col.

Value

  • None.

Details

The direction field is indicated variously, depending on the value of type. For type=1, each indicator is drawn with a symbol, according to the value of pch (either supplied globally, or as an element of the ... list) and of size cex, and colour col. Then, a line segment is drawn for each, and for this lwd and col may be set globally or in the ... list.

For type=2, the points are not drawn, but arrows are drawn instead of the line segments. Again, lwd and col control the type of the line.

Examples

Run this code
library(oce)
plot(c(-1.5, 1.5), c(-1.5, 1.5), xlab="", ylab="", type='n')
drawDirectionField(x=rep(0, 2), y=rep(0, 2), u=c(1,1), v=c(1, -1), scalex=0.5, add=TRUE)
plot(c(-1.5, 1.5), c(-1.5, 1.5), xlab="", ylab="", type='n')
drawDirectionField(x=rep(0, 2), y=rep(0, 2), u=c(1,1), v=c(1, -1), scalex=0.5, add=TRUE,
                   type=2)
plot(c(-1.5, 1.5), c(-1.5, 1.5), xlab="", ylab="", type='n')
drawDirectionField(x=rep(0, 2), y=rep(0, 2), u=c(1,1), v=c(1, -1), scalex=0.5, add=TRUE,
                   type=2, length=0.1)

Run the code above in your browser using DataLab