Learn R Programming

Boom (version 0.9.15)

compare.den: Compare several density estimates.

Description

Produces multiple density plots on a single axis, to compare the columns of a matrix or the elements of a list.

Usage

CompareDensities(x,
                 legend.text = NULL,
                 legend.location = "topright",
                 legend.title = NULL,
                 xlim = NULL,
                 ylim = NULL,
                 xlab = "parameter",
                 ylab = "density",
                 main = "",
                 lty = NULL,
                 col = "black",
                 axes = TRUE,
                 na.rm = TRUE,
                 ...)

Value

Called for its side effect, which is to produce multiple density plots on the current graphics device.

Arguments

x

matrix or list of numeric vectors. A density plot is produced for each column of the matrix or element of the list.

legend.text

(optional) character vector giving names of each density plot.

legend.location

Entry that can be passed to legend.

legend.title

The legend title.

xlim

(optional) horizonal range of the plotting region. If omitted the region will be sized to fit all the observations in x.

ylim

(optional) vertical range of the plotting region. If omitted the region will be sized to fit all empirical density plots.

xlab

label to be placed on the horizontal axis

ylab

label to be placed on the vertical axis

main

main title for the plot

lty

The line types to use for the different densities. See par. If NULL then a different line type will be used for each density.

col

vector of colors for the densities to be plotted.

axes

Logical. Should axes and a box be drawn around the figure?

na.rm

Logical value indicating whether NA's should be removed.

...

Other graphical parameters passed to plot.density, and lines.

Author

Steven L. Scott

See Also

Examples

Run this code

x <- t(matrix(rnorm(5000, 1:5, 1:5), nrow=5))
CompareDensities(x, legend.text=c("EJ", "TK", "JT", "OtherEJ", "TJ"),
                 col=rainbow(5), lwd=2)

Run the code above in your browser using DataLab