geom_density2d

geom_density2d(mapping=NULL, data=NULL, stat="density2d", position="identity", ...)

Contours from a 2d density estimate

Perform a 2D kernel density estimatation using kde2d and display the results with contours.

This page describes geom_density2d, see layer and qplot for how to create a complete plot from individual components.

Advice

This can be useful for dealing with overplotting.

What do you think of the documentation? Please let me know by filling out this short online survey.

Aesthetics

The following aesthetics can be used with geom_density2d. Aesthetics are mapped to variables in the data with the aes function: geom_density2d(aes(x = var)). Note that you do not need quotes around the variable name.

Scales control how the variable is mapped to the aesthetic and are listed after each aesthetic.

Aesthetic Default Related scales
xrequiredcontinuous, date, datetime, discrete
yrequiredcontinuous, date, datetime, discrete
weight1
colour#3366FFbrewer, gradient, gradient2, gradientn, grey, hue, identity, manual
size0.5identity, manual, size
linetype1identity, linetype, manual
alpha1

Layers are divided into groups by the group aesthetic. By default this is set to the interaction of all categorical variables present in the plot.

Parameters

Parameters control the appearance of the geom. In addition to the parameters listed below (if any), any aesthetic can be used as a parameter, in which case it will override any aesthetic mapping.

Returns

This function returns a layer object.

See also

Examples

> # See stat_density2d for examples 

What do you think of the documentation? Please let me know by filling out this short online survey.