Produce ggplot of densities from kde objects in 1 or 2 dimensions
Source:R/ggplot.R
autoplot.kde.Rd
Produce ggplot of densities from kde objects in 1 or 2 dimensions
Arguments
- object
Probability density function as estimated by
ks::kde()
.- prob
Probability of the HDR contours to be drawn (for a bivariate plot only).
- fill
If
TRUE
, and the density is bivariate, the bivariate contours are shown as filled regions rather than lines.- show_hdr
If
TRUE
, and the density is univariate, then the HDR regions specified byprob
are shown as a ribbon below the density.- show_points
If
TRUE
, then individual points are plotted.- show_mode
If
TRUE
, then the mode of the distribution is shown.- show_lookout
If
TRUE
, then the observations with lookout probabilities less than 0.05 are shown in red.- color
Color used for mode and HDR contours. If
fill
, this is the base color used in constructing the palette.- alpha
Transparency of points. When
fill
isFALSE
, defaults to min(1, 1000/n), where n is the number of observations. Otherwise, set to 1.- ...
Additional arguments are currently ignored.
Details
This function produces a ggplot of the density estimate produced by ks::kde()
.
For univariate densities, it produces a line plot of the density function, with
an optional ribbon showing some highest density regions (HDRs) and/or the observations.
For bivariate densities, it produces a contour plot of the density function, with
the observations optionally shown as points.
The mode can also be drawn as a point with the HDRs.
For bivariate densities, the combination of fill = TRUE
, show_points = TRUE
,
show_mode = TRUE
, and prob = c(0.5, 0.99)
is equivalent to an HDR boxplot.
For univariate densities, the combination of show_hdr = TRUE
, show_points = TRUE
,
show_mode = TRUE
, and prob = c(0.5, 0.99)
is equivalent to an HDR boxplot.