Learn R Programming

ocean (version 0.1-0)

spaghetti: Draw spaghetti lines of trajectories.

Description

Using the trajectories given by x and y, spaghetti draws lines along each trajectory. The lines are colored using the passed in function col. x and y should be 2d matrices with particles along the first axis and time along the second axis.

Usage

spaghetti(x, y, col=heat.colors, add=F, lwd=1)

Arguments

x
x locations.
y
y locations.
col
A function that takes 1 argument n, and returns n colors that will be used to color the trajectories.
add
Should the lines be added to the current plot.
lwd
Line width. See par

Examples

Run this code
# Create a set of random trajectories.
x <- matrix(rnorm(10000), 100)
y <- matrix(rnorm(10000), 100)
for(i in seq(100)) {
  x[i,] <- cumsum(x[i,])
  y[i,] <- cumsum(y[i,])
}
spaghetti(x, y, col=jet.colors)

Run the code above in your browser using DataLab