a <- rnorm(10)
b <- rnorm(10)
# an ugly imitation of a kde2d estimate
# since we don't want to load MASS just for an exemple
f1 <- structure(list(x = c(-3.1, -1.575, -0.05, 1.475, 3),
                     y = c(-3.213, -1.591, 0.032, 1.654, 3.276),
                     z = structure(c(0, 0, 0.003, 0, 0, 0,
                                     0.009, 0.05, 0.015,
                                     0, 0.001, 0.05, 0.152,
                                     0.052, 0.003, 0, 0.01,
                                     0.039, 0.028, 0.001, 0,
                                     0, 0.001, 0, 0),
                                   .Dim = c(5L, 5L))),
                     .Names = c("x", "y", "z"))
quant <- kde2dQuantile(f1, a, b, c(.05, .5))
contour(f1, levels = quant, labels = names(quant))
Run the code above in your browser using DataLab