Learn R Programming

CorReg (version 1.2.17)

matplot_zone: Matplot with curves comparison by background colors.

Description

Plot the columns of one matrix against the columns of another, with conditionnal background for easier comparison of curves.

Usage

matplot_zone(
  x = x,
  y = y,
  col = 1:6,
  alpha = 0.2,
  what = which.min,
  ylim = NULL,
  xlim = NULL,
  type = "p",
  xlab = NULL,
  ylab = NULL,
  ...
)

Arguments

x

the abscisses

y

matrix of the curves (columns)

col

list of colors (like in matplot)

alpha

parameter for transparency of the background

what

a function to choose a winner. Takes y as an input and must return a vector of colors (can be positive integers) of size length(x)

ylim

ranges of y axe

xlim

ranges of x axe

type

character string (length 1 vector) or vector of 1-character strings indicating the type of plot for each column of y. The first character of type defines the first plot, the second character the second, etc. Characters in type are cycled through; e.g., "pl" alternately plots points and lines.

xlab

title for x axe

ylab

title for y axe

...

Other graphical parameters

Examples

Run this code
# NOT RUN {
n = 15
x = 1:n
y = cbind(c(rnorm(5, 0, 1), rnorm(5, 1, 1), rnorm(5, 2, 1)),
          c(rnorm(5, 0, 1), rnorm(5, 1, 1), rnorm(5, 4, 1)),
          c(rnorm(5, 1, 3), rnorm(5, 1, 2), rnorm(5, 1, 1)))
matplot_zone(x, y, type = "l", what = which.max, main = "Highest curve")
# background color follows color of the highest curve
matplot_zone(x, y, type = "l", what = which.min, main = "Lowest curve")
# background color follows color of the lowest curve


# }

Run the code above in your browser using DataLab