plotnine.stat_ydensity

stat_ydensity(mapping=None, data=None, **kwargs)

Density estimate

{usage}

Parameters

kernel : str = "gaussian"

Kernel used for density estimation. One of:

"biweight"
"cosine"
"cosine2"
"epanechnikov"
"gaussian"
"triangular"
"triweight"
"uniform"
adjust : float = 1

An adjustment factor for the bw. Bandwidth becomes bw * adjust. Adjustment of the bandwidth.

trim : bool = False

This parameter only matters if you are displaying multiple densities in one plot. If False, the default, each density is computed on the full range of the data. If True, each density is computed over the range of that group; this typically means the estimated x values will not line-up, and hence you won’t be able to stack density values.

n : int = 1024

Number of equally spaced points at which the density is to be estimated. For efficient computation, it should be a power of two.

bw : str | float = "nrd0"

The bandwidth to use, If a float is given, it is the bandwidth. The str choices are:

"nrd0"
"normal_reference"
"scott"
"silverman"

nrd0 is a port of stats::bw.nrd0 in R; it is eqiuvalent to silverman when there is more than 1 value in a group.

scale : Literal[area, count, width] = "area"

How to scale the violins. The options are: If area all violins have the same area, before trimming the tails. If count the areas are scaled proportionally to the number of observations. If width all violins have the same maximum width.

See Also

geom_violin

The default geom for this stat.

KDEUnivariate
fit