plotnine.stat_density_2d
stat_density_2d(=None,
mapping=None,
data*,
="density_2d",
geom="identity",
position=False,
na_rm=True,
contour="statsmodels",
package=None,
kde_params=64,
n=5,
levels**kwargs
)
Compute 2D kernel density estimation
Parameters
mapping : aes = None
-
Aesthetic mappings created with aes. If specified and
inherit_aes=True
, it is combined with the default mapping for the plot. You must supply mapping if there is no plot mapping.Aesthetic Default value x The bold aesthetics are required.
Options for computed aesthetics
"level" # density level of a contour "density" # Computed density at a point "piece" # Numeric id of a contour in a given group
level
is only relevant when contours are computed.density
is available only when no contours are computed.piece
is largely irrelevant. data : DataFrame = None
-
The data to be displayed in this layer. If
None
, the data from from theggplot()
call is used. If specified, it overrides the data from theggplot()
call. geom : str | geom = "density_2d"
-
The statistical transformation to use on the data for this layer. If it is a string, it must be the registered and known to Plotnine.
position : str | position = "identity"
-
Position adjustment. If it is a string, it must be registered and known to Plotnine.
na_rm : bool = False
-
If
False
, removes missing values with a warning. IfTrue
silently removes missing values. contour : bool = True
-
Whether to create contours of the 2d density estimate.
n : int = 64
-
Number of equally spaced points at which the density is to be estimated. For efficient computation, it should be a power of two.
levels : int | array_like = 5
-
Contour levels. If an integer, it specifies the maximum number of levels, if array_like it is the levels themselves.
package : Literal[statsmodels, scipy, sklearn] = "statsmodels"
-
Package whose kernel density estimation to use.
kde_params : dict
-
Keyword arguments to pass on to the kde class.
**kwargs : Any = {}
-
Aesthetics or parameters used by the
geom
.