Learn R Programming

Boom (version 0.9.15)

plot.density.contours: Contour plot of a bivariate density.

Description

Contour plot of one ore more bivariate densities. This function was originally created to implement PairsDensity, but might be useful on its own.

Usage

PlotDensityContours(draws,
                    x.index = 1,
                    y.index = 2,
                    xlim = NULL,
                    ylim = NULL,
                    nlevels = 20,
                    subset = NULL,
                    color = NULL,
                    lty = NULL,
                    axes = TRUE,
                    ...)

Arguments

draws

Either a matrix or a list of matrices. If a list is provided then each list element is plotted as a separate set of contours, and all matrices must have the same number of columns (though the number of rows can differ).

x.index

The index of the parameter to plot on the horizonal axis.

y.index

The index of the beta coefficient to plot on the vertical axis.

xlim

Limits on the horizontal axis. If NULL then the plot is just wide enough to fit the contours.

ylim

Limits on the vertical axis. If NULL then the plot is just tall enough to fit the contours.

nlevels

The number of contour levels to plot.

subset

If draws is a list, then this can be a numerical vector. If draws has names, then subset can be a character vector naming which elements to include. If NULL then all elements of draws are plotted.

color

The color to use for different elemetns in draws.

lty

The line types to use for the different elements in draws.

axes

Logical. Should x and y axies be drawn?

...

Extra arguments passed to contour.

Author

Steven L. Scott

See Also

Examples

Run this code
## You can see the pairs plot for a single set of draws.
y <- matrix(rnorm(5000, mean = 1:5), ncol = 5, byrow = TRUE)
PlotDensityContours(y, 3, 1)

## You can also compare two or more sets of draws.
z <- matrix(rnorm(2500, mean = 2:6), ncol = 5, byrow = TRUE)
PlotDensityContours(list("first set" = y, "second set" = z), 3, 1)

Run the code above in your browser using DataLab