stat_ydensity {ggplot2}R Documentation

1d kernel density estimate along y axis, for violin plot.

Description

1d kernel density estimate along y axis, for violin plot.

Usage

  stat_ydensity(mapping = NULL, data = NULL,
    geom = "violin", position = "dodge", adjust = 1,
    kernel = "gaussian", trim = TRUE, scale = "area",
    na.rm = FALSE, ...)

Arguments

trim

If TRUE (default), trim the tails of the violins to the range of the data. If FALSE, don't trim the tails.

scale

if "area" (default), all violins have the same area (before trimming the tails). If "count", areas are scaled proportionally to the number of observations. If "width", all violins have the same maximum width.

na.rm

If FALSE (the default), removes missing values with a warning. If TRUE silently removes missing values.

mapping

The aesthetic mapping, usually constructed with aes or aes_string. Only needs to be set at the layer level if you are overriding the plot defaults.

data

A layer specific dataset - only needed if you want to override the plot defaults.

geom

The geometric object to use display the data

position

The position adjustment to use for overlappling points on this layer

adjust

see density for details

kernel

kernel used for density estimation, see density for details

...

other arguments passed on to layer. This can include aesthetics whose values you want to set, not map. See layer for more details.

Value

A data frame with additional columns:

density

density estimate

scaled

density estimate, scaled to maximum of 1

count

density * number of points - probably useless for violin plots

violinwidth

density scaled for the violin plot, according to area, counts or to a constant maximum width

n

number of points

width

width of violin bounding box

Aesthetics

stat_ydensity understands the following aesthetics (required aesthetics are in bold):

See Also

geom_violin for examples, and stat_density for examples with data along the x axis.

Examples

# See geom_violin for examples
# Also see stat_density for similar examples with data along x axis

[Package ggplot2 version 0.9.3.1 Index]