Skip to main content
A coordinate system decides the plane a geom is drawn in. The same geom and scales give very different charts under different coords: a stacked bar is a stacked column in cartesian coordinates, a horizontal bar when the axes are flipped, and a pie when the plane is bent into a circle. Set the coordinate system by piping a coord.*() part into the spec. When you don’t, the chart is cartesian.

Cartesian

The standard x–y plane, and the default.

Flip

coord.flip() swaps the x and y axes. Its main use is turning vertical columns into horizontal bars: keep the natural mapping (band on x, value on y) and the flip lays it on its side.

Polar

coord.polar() bends the plane into a circle. This is how pie, donut, rose and radial charts are made. It takes:
'x' | 'y'
default:"x"
Which aesthetic maps to the angle. theta: 'y' sweeps the value around the circle (pie, donut); theta: 'x' sweeps the band around it, with the value as radius (rose). A bare coord.polar() gives the rose form; pass theta: 'y' for a pie.
number
default:"0"
Inner radius as a fraction 0–1. 0 is a full pie; a value like 0.5 cuts out the center for a donut.
number
default:"0"
Starting angle in degrees.
A pie chart is a single stacked-fill bar wrapped around theta: 'y'. The 'fill' position normalizes the stack to 100%, which is what closes the circle:
The rest of the polar family comes from the same two options: See Pie & donut and Radar & radial for worked examples. Polar coordinates also set the padding of every discrete scale to 0, so wedges meet edge to edge and scale.x.discrete({ padding: 0.2 }) has no effect inside a pie.

Time around the circle

Mapping time to the angle turns a chart into a clock or a calendar: a day of tide heights, a year of temperatures. Pair theta: 'x' with a datetime or continuous x-scale:
Each reading gets its own slot. The turn closes one step past the last reading, so it never lands back on the first. The step is the median spacing, so twelve monthly readings close on the following January and each month keeps its true width. See Radar & radial for a rendered example. A numeric axis works the same way: a wind rose binned every 10 degrees gives 350 its own slot before the turn wraps back to 0. A log or sqrt x-scale keeps its data domain, since an even step there is not an even slot. When the circle stands for a fixed period, name its bounds, so a missing reading cannot shift the others. The inferred step only knows the readings it is given:

One coord per spec

Only one coordinate system applies at a time. Piping a second coord.*() replaces the first; it does not merge:

Next