Learn R Programming

Momocs (version 0.2-03)

dev.plot: Calculates and plots series with associated error bars.

Description

This function is used internally by methods based on deviations for one one many outlines. Yet, it provides a quick way to create plots of series, possibly with deviations, from scratch.

Usage

dev.plot(mat, dev, cols, x=1:ncol(mat), 
                           lines=TRUE, poly=TRUE, segments=FALSE, bw=0.1,
                           plot=FALSE, main="Deviation plot", xlab="", ylab="Deviations")

Arguments

mat
A matrix containing one or many lines (as individuals) with the corresponding y values (as cols).
dev
A matrix of the same dimension as mat but containing the deviation from the mat matrix.
cols
A vector of ncol(mat) colors.
x
An alternative vector of values for every column of mat.
lines
logical. Whether to draw lines for mean values.
poly
logical. Whether to draw polygons for mean + dev values.
segments
logical. Whether to draw segments for these mean + dev values.
bw
numeric. The width of the errors bars to draw.
plot
logical. Whether to plot a new graphical window.
main
character. A title for the plot.
xlab
character. A title for the x-axis.
ylab
character. A title for the y-axis.

Examples

Run this code
# we prepare some fake data
foo.mat  <- matrix(1:10, nr=3, nc=10, byrow=TRUE) + rnorm(30, sd=0.5)
foo.mat  <- foo.mat + matrix(rep(c(0, 2, 5), each=10), 3, byrow=TRUE)
foo.dev  <- matrix(abs(rnorm(30, sd=0.5)), nr=3, nc=10, byrow=TRUE)
# some possible tuning
dev.plot(foo.mat, plot=TRUE)
dev.plot(foo.mat, foo.dev, plot=TRUE)
dev.plot(foo.mat, foo.dev, lines=TRUE, plot=TRUE)
dev.plot(foo.mat, foo.dev, poly=FALSE, segments=TRUE, lines=TRUE, plot=TRUE)
dev.plot(foo.mat, foo.dev, cols=col.sari(3), poly=FALSE, segments=TRUE, lines=TRUE, plot=TRUE)
dev.plot(foo.mat, foo.dev, cols=col.summer(6)[4:6], plot=TRUE)

Run the code above in your browser using DataLab