phasePortrait {phaseR}R Documentation

Phase portrait plot

Description

For a one-dimensional autonomous ODE, it plots the phase portrait, i.e., the derivative against the dependent variable. In addition, along the dependent variable axis it plots arrows pointing in the direction of dependent variable change with increasing value of the independent variable. From this stability of equilibrium points (i.e., locations where the horizontal axis is crossed) can be determined.

Usage

phasePortrait(
  deriv,
  ylim,
  ystep = 0.01,
  parameters = NULL,
  points = 10,
  frac = 0.75,
  arrow.head = 0.075,
  col = "black",
  add.grid = TRUE,
  state.names = "y",
  xlab = state.names,
  ylab = paste0("d", state.names),
  ...
)

Arguments

deriv

A function computing the derivative at a point for the ODE system to be analysed. Discussion of the required structure of these functions can be found in the package vignette, or in the help file for the function ode.

ylim

Sets the limits of the dependent variable for which the derivative should be computed and plotted. Should be a numeric vector of length two.

ystep

Sets the step length of the dependent variable vector for which derivatives are computed and plotted. Decreasing ystep makes the resulting plot more accurate, but comes at a small cost to computation time. Defaults to 0.01.

parameters

Parameters of the ODE system, to be passed to deriv. Supplied as a numeric vector; the order of the parameters can be found from the deriv file. Defaults to NULL.

points

Sets the density at which arrows are plotted along the horizontal axis; points arrows will be plotted. Fine tuning here, by shifting points up and down, allows for the creation of more aesthetically pleasing plots. Defaults to 10.

frac

Sets the fraction of the theoretical maximum length line segments can take without overlapping, that they actually attain. Fine tuning here assists the creation of aesthetically pleasing plots. Defaults to 0.75.

arrow.head

Sets the length of the arrow heads. Passed to arrows. Defaults to 0.075.

col

Sets the colour of the line in the plot, as well as the arrows. Should be a character vector of length one. Will be reset accordingly if it is of the wrong length. Defaults to "black".

add.grid

Logical. If TRUE, a grid is added to the plot. Defaults to TRUE.

state.names

The state names for ode functions that do not use positional states.

xlab

Label for the x-axis of the resulting plot.

ylab

Label for the y-axis of the resulting plot.

...

Additional arguments to be passed to either plot or arrows.

Value

Returns a list with the following components:

add.grid

As per input.

arrow.head

As per input.

col

As per input, but with possible editing if a character vector of the wrong length was supplied.

deriv

As per input.

dy

A numeric vector containing the value of the derivative at each evaluated point.

frac

As per input.

parameters

As per input.

points

As per input.

xlab

As per input.

y

A numeric vector containing the values of the dependent variable for which the derivative was evaluated.

ylab

As per input.

ylim

As per input.

ystep

As per input.

Author(s)

Michael J Grayling

See Also

arrows, plot

Examples

# A one-dimensional autonomous ODE system, example2.
example2_phasePortrait <- phasePortrait(example2,
                                        ylim   = c(-0.5, 2.5),
                                        points = 10,
                                        frac   = 0.5)

[Package phaseR version 2.2.1 Index]