Display a smooth density estimate
An area plot is the continuous analog of a stacked bar chart (see geom_bar), and can used to show how composition of the whole varies over the range of x. Choosing the order in which different components is stacked is very important, as it becomes increasing hard to see the indivudual pattern as you move up the stack.
An area plot is a special case of geom_ribbon, where the minimum of the range is fixed to 0, and the position adjustment defaults to position_stacked.
See layer and qplot for more information on creating a complete plot from multiple components.
The following aesthetics can be used with geom_density. 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(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: black
(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(fill = 3)
, it will override mappings from data.
fill
, internal colourweight
, observation weight used in statistical transformationcolour
, border coloursize
, sizelinetype
, line typestat_density. Override with the stat
argument: geom_density(stat="identity")
position_stack. Override with the position
argument: geom_density(position="jitter")
.