Contours from a 2d density estimate
Perform a 2D kernel density estimatation using \code{\link{kde2d}} and display the results with contours. This is another function useful for dealing with overplotting.
See layer and qplot for more information on creating a complete plot from multiple components.
The following aesthetics can be used with geom_density_2d. They are listed along with their default value. All geoms and scales can also use the group aesthetic. Read how this important aesthetic works in scale_group. Typically, you will associate an aesthetic with a variable in your data set. To do this, you use the aes function: geom_density_2d(aes(x = var))
. Scales control the details of the mapping between data and aesthetic properties; after each aesthetic are listed scales that can be used with that aesthetic. The scale documentation will also provide references to help you interpret the default values.
Instead of mapping an aesthetic to a variable in your dataset, you can also set it to a fixed value. See the parameters section for details.
weight: 1
colour: grey50
(scales: brewer, gradient, gradient2, hue, manual)
size: 1
(scales: area, manual, size, size_discrete)
When an aesthetic is used an a parameter, like geom_density_2d(weight = 3)
, it will override mappings from data.
weight
, observation weight used in statistical transformationcolour
, border coloursize
, sizelinetype
, line typestat_density_2d. Override with the stat
argument: geom_density_2d(stat="identity")
position_identity. Override with the position
argument: geom_density_2d(position="jitter")
.