A vector with quantities (velocities) in x-direction.
v
A vector with quantities (velocities) in y-direction.
Should have the same length as u
x
A vector with x-axis values. If 0, everything will
be radiating from the origin. Usually x will be equal to time.
y
The y-axis value. One number, or a vector of length = u.
colvar
The variable used for coloring. It need
not be present, but if specified, it should be a vector of
dimension equal to c(nrow(u), ncol(v)).
Values of NULL, NA, or FALSE
will toggle off coloration according to colvar.
col
Colors to be used for coloring the arrows as specified by the
colvar variable.
If col is NULL and colvar is specified,
then a red-yellow-blue colorscheme (jet.col) will be used.
If col is NULL and colvar is not specified, then
col will be "black".
NAcol
Colors to be used for colvar values that are NA.
breaks
a set of finite numeric breakpoints for the colors;
must have one more breakpoint than color and be in increasing order.
Unsorted vectors will be sorted, with a warning.
colkey
A logical, NULL (default), or a list with parameters
for the color key (legend). List parameters should be one of
side, plot, length, width, dist, shift, addlines, col.clab, cex.clab,
side.clab, line.clab, adj.clab, font.clab
and the axis parameters at, labels, tick, line, pos, outer, font, lty, lwd,
lwd.ticks, col.box, col.axis, col.ticks, hadj, padj, cex.axis, mgp, tck, tcl, las.
The defaults for the parameters are side = 4, plot = TRUE, length = 1, width = 1,
dist = 0, shift = 0, addlines = FALSE, col.clab = NULL, cex.clab = par("cex.lab"),
side.clab = NULL, line.clab = NULL, adj.clab = NULL, font.clab = NULL)
See colkey from package plot3D.
The default is to draw the color key on side = 4, i.e. in the right margin.
If colkey = NULL then a color key will be added only if col is a vector.
Setting colkey = list(plot = FALSE) will create room for the color key
without drawing it.
if colkey = FALSE, no color key legend will be added.
clim
Only if colvar is specified, the range of the colors, used
for the color key.
clab
Only if colkey is not NULL or FALSE,
the label to be written on top of the color key.
The label will be written at the same level as the main title.
To lower it, clab can be made a vector, with the first values empty
strings.
by
Number increment for plotting vectors.
Set this to an integer > 1 if the vector density is too high.
xfac
Only for x not NULL, the proportionality
factor with which the vectors on the x-axis must be drawn. A value of 1
means that the distance of one will be drawn as one x-unit on the x-axis.
For a value of 2 a distance of 1 will appear as 2 x-units on the x-axis.
if NULL, the range on the y-axis is used. In that case, it may be
necessary to manually set the xlim of the figure.
arr
If TRUE, then Arrows will be drawn;
if FALSE, segments will be drawn.
add
If TRUE, will add to the current plot.
...
additional arguments passed to the plotting methods.
Value
none
See Also
quiver2D, flowpath, for other functions to plot velocities.
Examples
# save plotting parameters
mf <- par("mfrow")
## =======================================================================
## EXAMPLE 1:
## =======================================================================
par(mfrow = c(2, 2))
u <- cos(seq(0, 2*pi, 0.1))
v <- sin(seq(0, 2*pi, 0.1)+ 1)
vectorplot(u = u, v = v)
vectorplot(u = u, v = v, col = 1:10)
x <- seq(0, 1, length.out = length(u))
vectorplot(u = u, v = v, x = x, xfac = 3)
points(x, rep(0, length(u)), pch = "+", col = "red")
vectorplot(u = u, v = v, x = 1:length(u), xfac = 10)
## =======================================================================
## EXAMPLE 2: adding to a plot
## =======================================================================
par(mfrow = c(2, 2))
x <- 1:length(u)
plot(x, u)
vectorplot(u = u, v = v, x = x, xfac = 10,
add = TRUE, col = "red")
vectorplot(u = u, v = v, x = x, xfac = 10,
colvar = sqrt(u^2+v^2), clab = "m/s")
vectorplot(u = u, v = v, x = x, xfac = 10,
colvar = sqrt(u^2+v^2), clab = "m/s", log = "c")
# reset plotting parameters
par(mfrow = mf)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(OceanView)
Loading required package: plot3D
Loading required package: plot3Drgl
Loading required package: rgl
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/OceanView/vectorplot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: vector plots
> ### Title: Vector velocity plot.
> ### Aliases: vectorplot
> ### Keywords: hplot
>
> ### ** Examples
>
> # save plotting parameters
> mf <- par("mfrow")
>
> ## =======================================================================
> ## EXAMPLE 1:
> ## =======================================================================
>
> par(mfrow = c(2, 2))
>
> u <- cos(seq(0, 2*pi, 0.1))
> v <- sin(seq(0, 2*pi, 0.1)+ 1)
>
> vectorplot(u = u, v = v)
> vectorplot(u = u, v = v, col = 1:10)
>
> x <- seq(0, 1, length.out = length(u))
> vectorplot(u = u, v = v, x = x, xfac = 3)
> points(x, rep(0, length(u)), pch = "+", col = "red")
>
> vectorplot(u = u, v = v, x = 1:length(u), xfac = 10)
>
> ## =======================================================================
> ## EXAMPLE 2: adding to a plot
> ## =======================================================================
>
> par(mfrow = c(2, 2))
> x <- 1:length(u)
> plot(x, u)
> vectorplot(u = u, v = v, x = x, xfac = 10,
+ add = TRUE, col = "red")
>
> vectorplot(u = u, v = v, x = x, xfac = 10,
+ colvar = sqrt(u^2+v^2), clab = "m/s")
>
> vectorplot(u = u, v = v, x = x, xfac = 10,
+ colvar = sqrt(u^2+v^2), clab = "m/s", log = "c")
>
> # reset plotting parameters
> par(mfrow = mf)
>
>
>
>
>
> dev.off()
null device
1
>