On this page
Coords
Plot coordinate systems. Compose declaration-only shells such as CoordFlip and CoordFixed, or portable helpers such
as coordTransform. Coords are a REPLACE family (last
registration wins). Narrative guide: Facets and coordinates.
6 coords
All coords
CoordCartesianDefault Cartesian coordinates. Omit coord or use CoordCartesian to clear a prior REPLACE-family coord; normalize() drops bare { type: "cartesian" }.CoordFlipSwap display axes so semantic x paints vertically and y horizontally. The mechanism for horizontal bar charts; stack, dodge, and hit-testing follow the flip.CoordTransformPost-stat coordinate projection with independent x/y transforms (identity, log10, sqrt), semantic viewport limits, reverse, and panel clipping. Distinct from pre-stat scale transforms.CoordFixedFixed physical data-unit aspect ratio (y-unit length / x-unit length). Layout fits the largest centered data rectangle after chart chrome; rejects free positional facet scales.CoordSfFixed-aspect coordinates for already-projected geom_sf maps. Same layout as fixed; no CRS reproject or graticules in v1 — data must already be in plot space.CoordRadialPolar/radial coordinates (ggplot2 coord_radial). Maps one aesthetic to angle and the other to radius for pie charts, coxcombs, and polar scatter. coord_polar is a helper alias with clip on.
How to set a coord
Prefer a typed shell as a child of <GGPlot>. Coords
replace whole; only one coord is active. Omit coord for default Cartesian.
import { GGPlot, GeomCol, CoordFlip } from "@ggsvelte/svelte";
<GGPlot data={rows} aes={{ x: "category", y: "value" }}>
<GeomCol />
<CoordFlip />
</GGPlot> Portable helpers assemble the same JSON for the builder or normalize():
import { coordFixed, coordTransform } from "@ggsvelte/spec";
coordFixed({ ratio: 1 })
// → { type: "fixed" }
coordTransform({ x: "log10", y: { transform: "sqrt", reverse: true } })
// → { type: "transform", x: { transform: "log10" }, y: { transform: "sqrt", reverse: true } } Builder sugar includes .coordFlip(), .coordTransform(…), .coordFixed(…), .coordEqual(…), and .coordSf(…), plus .coord(…) for a full CoordSpec or the "flip" shorthand.
Escape hatch
For a computed fragment, use <Coord value={spec} /> where value is a CoordSpec or "flip". Named
shells are preferred when the form is known at authoring time.
import { GGPlot, GeomPoint, Coord } from "@ggsvelte/svelte";
const coord = condition ? { type: "flip" } : { type: "fixed", ratio: 2 };
<GGPlot data={rows} aes={{ x: "x", y: "y" }}>
<GeomPoint />
<Coord value={coord} />
</GGPlot> <CoordCartesian /> registers { type: "cartesian" }, which normalize() drops when bare — useful mid-migration under REPLACE
so a child can clear a prior flip or fixed coord.