# crit-density: Draw density contour plot using a cut-off value. In markheckmann/convexhull: Drawing convex hulls

## Description

Draw density contour plot using a cut-off value.

## Usage

 ```1 2 3``` ```crit_contour(den, n = 100, prob = 0.05, ...) crit_dens_image(den, prob = 0.05, ...) ```

## Arguments

 `den` Object returned by `kde2d`. `n` A bit uncelar needs a check. `prob` Probability used to determine critical cut-off value for density. `...` Passes to image or contour.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35``` ```library(RColorBrewer) library(MASS) # example 1 n <- 100 set.seed(0) x <- rnorm(n, 3) y <- rnorm(n, 3) plot(x,y) den <- kde2d(x, y, n=100) # estimate non-parameteric density surface via kernel smoothing cols = set_alpha_color_value(heat.colors(12), .1) crit_dens_image(den, col=cols, prob=.1) crit_contour(den, n=100, col="red", drawlabels=FALSE, prob=.1) # example 2 n <- 200 set.seed(0) x <- rnorm(n, c(1,3)) y <- rnorm(n, c(1,3)) d <- data.frame(x,y, g=1:2) plot(x,y, pch=16, cex=.7, col=1:2) g1 <- subset(d, g==1) g2 <- subset(d, g==2) den1 <- kde2d(g1\$x, g1\$y, n=100) # estimate non-parameteric density surface via kernel smoothing den2 <- kde2d(g2\$x, g2\$y, n=100) # estimate non-parameteric density surface via kernel smoothing reds <- set_alpha_color_value("red", seq(.05, 1, len=20)) blues <- set_alpha_color_value("blue", seq(.05, 1, len=20)) # cols <- colorRampPalette(c("white", "darkred"))(10) # cols <- set_alpha_color_value(cols, alpha=.5) crit_dens_image(den1, col=blues, prob=.3) crit_contour(den1, n=100, lty=3, drawlabels=FALSE, prob=.3) crit_dens_image(den2, col=reds, prob=.3) crit_contour(den2, n=100, lty=3, drawlabels=FALSE, prob=.3) ```

markheckmann/convexhull documentation built on May 21, 2019, 12:06 p.m.