Guides and legends

Appearance-only guides keyed by aesthetic. Compose declaration-only shells such as GuideLegend and GuideColorbar, or portable helpers such as guideLegend. Placement here is guide position (right/bottom) — not geom position adjustments (stack, dodge, jitter).

5 guides

All guides

How to set a guide

Prefer a typed shell with a channel prop. Guides merge by channel; the value at a channel is replaced whole. Top-level guide children win over a scale-local guide on the same aesthetic.

import { GGPlot, GeomPoint, GuideLegend } from "@ggts-sh/svelte";

<GGPlot data={rows} aes={{ x: "displ", y: "hwy", color: "class" }}>
  <GeomPoint />
  <GuideLegend channel="color" position="bottom" direction="horizontal" />
</GGPlot>

Portable helpers assemble the same JSON for the builder or normalize():

import { guideLegend, guides } from "@ggts-sh/spec";

guides({ color: guideLegend({ position: "bottom" }) })
// → { guides: { color: { type: "legend", position: "bottom" } } }

For a computed multi-channel bag, use the escape hatch <Guides value={…} />. Suppress one channel with GuideNone.

Legend focus, filter, and clear recovery

Discrete color and fill legends can host interaction controls when <GuideLegend focus /> or <GuideLegend filter /> is enabled for that aesthetic. Do not put legendFocus / legendFilter on <GGPlot> — those plot props are deprecated dual-reads. Focus is presentation emphasis only; Clear legend focus restores the unfocused view without changing data. Filter changes included rows. Authoring the guide itself is separate — see GuideLegend, the interaction reference, and the legend focus example.