GeomDensity2d

2D density geometry: bivariate KDE isolines over continuous x and y. Open path contours.

Defaults

geom
density_2d
default stat
density_2d
default position
identity
params type
Density2dParams

Svelte component

import { GGPlot, GeomDensity2d } from "@ggsvelte/svelte";

<GGPlot data={rows} aes={{ x: "x", y: "y" }}>
  <GeomDensity2d />
</GGPlot>

JSON layer

{
  "geom": "density_2d",
  "stat": "density_2d"
}

Params

h

number | Array<number>

Kernel bandwidth: one positive number for both axes, or [hx, hy]. Omit for MASS bandwidth.nrd per axis (then kde2d h/4 scaling).

adjust

number

Bandwidth multiplier (must be greater than 0). Default 1.

n

number

Grid resolution per axis for the KDE surface (integer 10–200). Default 100.

bins

number

Number of contour levels of the density surface (integer ≥ 1). Default 10. Overridden by breaks.

binwidth

number

Contour level step in density units. Overridden by breaks.

breaks

Array<number>

Explicit density contour levels. Overrides bins and binwidth.

linewidth

number

Stroke width of density contours in px. Must be greater than 0. Default 1.

alpha

number

Line opacity. Must be between 0 and 1 (inclusive). Default 1.

Allowed stats

Allowed positions

Examples

← All geoms · Getting started