kdeplot¶
kdeplot(data, *, x=None, y=None, hue=None, hue_order=None, bw_adjust=1.0, cut=3.0, gridsize=200, color=None, palette=None)
¶
Plot a kernel density estimate using Silverman's rule.
Uses a Gaussian kernel with bandwidth selected via Silverman's rule of thumb,
scaled by bw_adjust. The evaluation grid is always evenly spaced, satisfying
Mermaid's equidistant constraint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
IntoFrame
|
Input data. Any narwhals-compatible DataFrame or LazyFrame. |
required |
x
|
str | None
|
Column name for horizontal density (mutually exclusive with |
None
|
y
|
str | None
|
Column name for vertical density (mutually exclusive with |
None
|
hue
|
str | None
|
Column name for grouping into separate series. |
None
|
hue_order
|
list | None
|
Explicit order for hue levels. |
None
|
bw_adjust
|
float
|
Multiplicative factor applied to the Silverman bandwidth. Values > 1 produce smoother curves. |
1.0
|
cut
|
float
|
Number of bandwidths to extend the grid beyond the data range. |
3.0
|
gridsize
|
int
|
Number of evaluation points on the density grid. |
200
|
color
|
str | None
|
Single colour for the line (CSS colour string). |
None
|
palette
|
list | None
|
List of colours, one per hue level. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
XYChart |
XYChart
|
An instance ready to render or further configure. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither or both of |