plotnine.stat_density
stat_density(mapping=None, data=None, **kwargs)Compute 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 becomesbw * 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. IfTrue, 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.
gridsize : int = None-
If gridsize is
None,max(len(x), 50)is used. bw : str | float = "nrd0"-
The bandwidth to use, If a float is given, it is the bandwidth. The options are:
"nrd0" "normal_reference" "scott" "silverman"nrd0is a port ofstats::bw.nrd0in R; it is eqiuvalent tosilvermanwhen there is more than 1 value in a group. cut : float = 3-
Defines the length of the grid past the lowest and highest values of
xso that the kernel goes to zero. The end points are-/+ cut*bw*{min(x) or max(x)}. clip : tuple[float, float] = (-inf, inf)-
Values in
xthat are outside of the range given by clip are dropped. The number of values inxis then shortened. bounds-
The domain boundaries of the data. When the domain is finite the estimated density will be corrected to remove asymptotic boundary effects that are usually biased away from the probability density function being estimated.
See Also
geom_density-
The default
geomfor thisstat. KDEUnivariatefit