For this tutorial we are going to use the following sample data, which consists on ten realizations of a brownian motion. The corresponding data for each path is a column of the B
matrix.
matplot
function
In order to create a line chart with all the columns of the data at the same time you can make use of matplot
and setting type = "l"
. Note that B
is a numeric matrix, but could also be a data frame or a vector and a matrix.
By default, the function uses colors 1 to 6, line width of 1 and line types 1 to 5 to create the lines, but his can be overridden with arguments col
, lwd
and lty
, respectively.
matlines
function
The matlines
function is to matplot
the same as lines
is to plot
. It allows you adding more lines from a data frame or matrix to the previous plot. In the following example we are using it to highlight some paths of the brownian motion.
See also