KDE Chart 3D
Signature
sp.build_kde3d_chart(
title: str,
x: list[float],
y: list[float],
*,
bandwidth: float = 1.0,
resolution: int = 50,
palette: list[int] | None = None,
bg_color: str = "#1a1a2e",
width: int = 900,
height: int = 600,
x_label: str = "X",
y_label: str = "Y",
z_label: str = "Density",
) -> Chart
Aliases: sp.kde3d
Description
2D Kernel Density Estimation rendered as a 3D surface mesh over a grid. Visualizes the joint density of two variables.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
title | str | required | Chart title |
x | list[float] | required | X sample data |
y | list[float] | required | Y sample data |
bandwidth | float | 1.0 | KDE bandwidth factor |
resolution | int | 50 | Grid resolution (n × n) |
palette | list[int] | None | None | Color gradient palette |
bg_color | str | "#1a1a2e" | Background color |
width | int | 900 | Canvas width |
height | int | 600 | Canvas height |
x_label | str | "X" | X-axis label |
y_label | str | "Y" | Y-axis label |
z_label | str | "Density" | Z-axis label |
Returns
Chart
Examples
import seraplot as sp
import random
values = (
[random.gauss(-2, 1) for _ in range(200)] +
[random.gauss(0, 0.8) for _ in range(200)] +
[random.gauss(3, 1.2) for _ in range(200)]
)
categories = ["Group A"] * 200 + ["Group B"] * 200 + ["Group C"] * 200
chart = sp.build_kde3d_chart(
"Density by Group",
values,
categories=categories,
)const sp = require('seraplot');
import random
const values = (
[random.gauss(-2, 1) for _ in range(200)] +
[random.gauss(0, 0.8) for _ in range(200)] +
[random.gauss(3, 1.2) for _ in range(200)]
)
const categories = ["Group A"] * 200 + ["Group B"] * 200 + ["Group C"] * 200
const chart = sp.build_kde3d_chart("Density by Group",
values,
{
categories: categories
})import * as sp from 'seraplot';
import random
const values = (
[random.gauss(-2, 1) for _ in range(200)] +
[random.gauss(0, 0.8) for _ in range(200)] +
[random.gauss(3, 1.2) for _ in range(200)]
)
const categories: string[] = ["Group A"] * 200 + ["Group B"] * 200 + ["Group C"] * 200
const chart = sp.build_kde3d_chart("Density by Group",
values,
{
categories: categories
})▶ Live Preview
See also
Signature
sp.build_kde3d_chart(
title: str,
x: list[float],
y: list[float],
*,
bandwidth: float = 1.0,
resolution: int = 50,
palette: list[int] | None = None,
bg_color: str = "#1a1a2e",
width: int = 900,
height: int = 600,
x_label: str = "X",
y_label: str = "Y",
z_label: str = "Density",
) -> Chart
Aliases: sp.kde3d
Description
Estimation par noyau 2D rendue comme une surface maillage 3D. Visualise la densité jointe de deux variables.
Paramètres
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
title | str | requis | Titre du graphique |
x | list[float] | requis | Données X |
y | list[float] | requis | Données Y |
bandwidth | float | 1.0 | Facteur de bande passante KDE |
resolution | int | 50 | Résolution de la grille (n × n) |
palette | list[int] | None | None | Palette de gradient de couleur |
bg_color | str | "#1a1a2e" | Couleur de fond |
width | int | 900 | Largeur du canvas |
height | int | 600 | Hauteur du canvas |
x_label | str | "X" | Étiquette de l'axe X |
y_label | str | "Y" | Étiquette de l'axe Y |
z_label | str | "Density" | Étiquette de l'axe Z |
Retourne
Chart
Exemples
import seraplot as sp
import random
x = [random.gauss(0, 1) for _ in range(400)]
y = [xi * 0.5 + random.gauss(0, 0.5) for xi in x]
chart = sp.build_kde3d_chart(
"Densité jointe X vs Y",
x=x, y=y,
x_label="X", y_label="Y", z_label="Densité",
)