Skip to contents

Like dnplot(), but using ggplot2.

Usage

density_plot(M, labs)

Arguments

M

A vector or matrix of values upon which the density plot is based; if a matrix, separate densities will be estimated and plotted for each column

labs

If supplied, a legend is printed; order of labs should correspond to columns of M

Examples

M <- cbind(rgamma(1000, 2, 2), rnorm(1000))
colnames(M) <- c('Gamma', 'Normal')
density_plot(M[,1])

density_plot(M)

density_plot(rexp(100, 2), labs='Exponential')

density_plot(data.frame(Gamma=rgamma(1000, 2, 2), Normal=rnorm(1000)))