mrfDepth (version 1.0.12)

mrainbowplot: Rainbow plot for bivariate data

Description

Makes a scatterplot of bivariate data and colors the observations according to their depth value.

Usage

mrainbowplot(x, depths, col = NULL, plot.options = list())

Arguments

x

An \(n\) by 2 data matrix.

depths

A column vector of length \(n\). The depth values of the observations in x. The coloring is based on these depth values.

col

An \(m > 2\) by 3 matrix. Colors in rgb format. The user may use this argument to set the colorscale of the depth range. The first row should contain the rgb values for the lowest depth value, the last row the rgb values of the color for the deepest depth value. Colors for other depth values are interpolated. When more then two rows are provided the color range will be equidistantly divided over the different colors.

plot.options

A list of available options:

  • legend.title Title of the legend. Defaults to "Depth".

  • point.size Numeric defining the size of the points in the plot. Defaults to 4.

Details

The plot is made using ggplot2. The plot itself is returned by the function and is fully customisable using standard ggplot2 commands. Similar plots for multivariate data with \(p > 2\) can be made using the ggpairs function in the library GGally.

Examples

Run this code
# NOT RUN {
data(cardata90)
Result <- projdepth(x = cardata90)
plot.options <- list(legend.title = "PD")
plot <- mrainbowplot(cardata90,
                     depths = Result$depthZ, plot.options = plot.options)
library("ggplot2")
plot + ggtitle("Rainbowplot of the cardata using projection depth.")

#The default color range may be adjusted using the col argument.
RGBmatrix <- c(1, 0, 0, #Red
               1, 1, 1, #White
               0, 1, 0) #Green
RGBmatrix <- matrix(RGBmatrix, ncol = 3, byrow = TRUE)
plot <- mrainbowplot(cardata90, 
                     depths = Result$depthZ, col = RGBmatrix,
                     plot.options = plot.options)
plot + ggtitle("Rainbowplot of the cardata using projection depth.")

# }

Run the code above in your browser using DataCamp Workspace