GeomFunction

Function geometry: evaluate a named portable function y = f(x) on a grid and draw a path. Requires params.fun; domain from params.xlim, mapped x, or peer layers.

Defaults

geom
function
default stat
function
default position
identity
params type
FunctionParams

Svelte component

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

<GGPlot data={rows} aes={{ x: "x", y: "y" }}>
  <GeomFunction
  fun={/* … */}
/>
</GGPlot>

JSON layer

{
  "geom": "function",
  "stat": "function",
  "params": { "fun": /* … */ }
}

Params

fun required

FunctionRegistryName

Required named function from the portable registry.

n

number

Number of evaluation grid points (2–10000). Default 101.

xlim

Array<number>

Evaluation domain [min, max] (min < max). When omitted, uses continuous aes.x extent or peer-layer x domain.

args

FunctionArgs

Optional named arguments for the registry function (e.g. mean and sd for dnorm). Keys and values must be portable JSON.

alpha

number

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

linewidth

number

Stroke width in px. Must be greater than 0. Default 1.5.

strokePaint

GradientPaint

Within-mark gradient stroke 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