Learn R Programming

ggplot2 (version 0.9.2.1)

stat_ydensity: 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 = "equal",
    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 "equal" (default), all violins have the same area (to be precise, they would have the same area if tails are not trimmed). If "count", the areas are scaled proportionally to the number of observations.
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:
  • widthwidth of violin bounding box
  • ydensitydensity estimate
  • scaleddensity estimate, scaled depending on scalearea and scalecount
  • countydensity * number of points
  • counttotalnumber of points

Aesthetics

[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "ydensity")} # See geom_violin for examples # Also see stat_density for similar examples with data along x axis geom_violin for examples, and stat_density for examples with data along the x axis.