GeomHistogram

Histogram geometry: a continuous x variable divided into bins, one bar per bin whose height is the count of rows (or the sum of aes.weight). Do not map aes.y — the bin stat computes it. Canonicalized by normalize() to a bar layer with stat bin.

Defaults

geom
histogram
default stat
bin
default position
stack
params type
BarParams

Alias

normalize() rewrites this geom to bar (with this alias's default stat and position). Prefer the canonical geom in new code.

Svelte component

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

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

JSON layer

{
  "geom": "histogram",
  "stat": "bin"
}

Params

alpha

number

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

width

number

Bar width as a fraction of the band step (count-stat bars only; binned bars span their bin). Must be greater than 0 and at most 1. Default 0.9.

bins

number

STAT BIN ONLY: number of bins (an integer of at least 1). Default 30 — an advisory reminds you to pick a real value. Overridden by binwidth.

binwidth

number

STAT BIN ONLY: bin width in data units (must be greater than 0). Takes precedence over bins. Usually the better knob: pick a width meaningful for the data.

boundary

number

STAT BIN ONLY: align a bin EDGE with this x value (e.g. 0 puts bin edges at multiples of the width). Mutually exclusive with center.

center

number

STAT BIN ONLY: align a bin CENTER with this x value. Mutually exclusive with boundary.

closed

"right" | "left"

STAT BIN ONLY: which edge of each bin is inclusive: "right" (default, matches) or "left".

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