GeomDensity

Density geometry: a smooth kernel density estimate of a continuous x variable, drawn as a filled area — a smoothed histogram alternative. One curve per group. Do NOT map aes.y — the density stat computes it.

Defaults

geom
density
default stat
density
default position
identity
params type
DensityParams

Svelte component

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

<GGPlot data={rows} aes={{ x: "x" }}>
  <GeomDensity />
</GGPlot>

JSON layer

{
  "geom": "density",
  "stat": "density"
}

Params

bw

number

Kernel bandwidth in data units (must be greater than 0). Omit for R's bw.nrd0 rule-of-thumb default.

adjust

number

Bandwidth multiplier (must be greater than 0). Default 1. 0.5 = half the default bandwidth (wigglier), 2 = double (smoother).

n

number

Number of grid points the density is evaluated at (an integer between 2 and 4096). Default 512 (the R default).

cut

number

The grid extends cut * bandwidth beyond the data extremes (at least 0). Default 3 (the R default).

alpha

number

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

fillPaint

GradientPaint

Within-mark gradient fill paint (not a data scale). Requires a solid fallback.

glow

GlowSpec

Bounded within-mark glow treatment (not theme decoration).

Allowed stats

Allowed positions

Examples

← All geoms · Getting started