Coord.clock
A polar coordinate system oriented like a clock face. 0° is at 12 o'clock (top) and angles increase clockwise. Ideal for pie charts, donut charts, and radial visualizations.
python
from gofish import chart, stack, spread, rect, Coord
chart(seafood, coord=Coord.clock()) \
.flow(stack(by="species", dir="x")) \
.mark(rect(w="count", fill="species")) \
.render(w=400, h=300)Signature
python
Coord.clock(
*,
inner_radius: float | None = None,
central_angle: float | None = None,
baseline_angle: float | None = None,
direction: int | None = None,
center: tuple[float, float] | None = None,
) -> CoordParameters
The polar transform in the clock convention: θ=0 at 12 o'clock, increasing clockwise. It differs from Coord.polar() only in the baselineAngle and direction defaults.
| Option | Type | Default | Description |
|---|---|---|---|
inner_radius | float | 0 | Donut hole as a fraction [0,1) of the outer radius. |
central_angle | float | 2π | Total angular sweep in radians. |
baseline_angle | float | π/2 | The angle where the angular axis's 0 sits: radians, measured counter-clockwise from 3 o'clock. Data 0 on θ maps here for every θ range and every sweep. |
direction | float | -1 | +1 counter-clockwise, -1 clockwise (numeric ±1). |
center | tuple | [0, 0] | Screen-space center offset. |
Coord.clock() is the Coord.polar() transform and accepts the same options — inner_radius, central_angle, baseline_angle, direction, center. Only the baseline_angle and direction defaults differ: 0° at 12 o'clock, clockwise. See polar's Parameters. As in polar, the number 0 on the angular axis always sits at baseline_angle.
Usage
Pass the coordinate transform to chart via the coord keyword:
python
chart(data, coord=Coord.clock()) \
.flow(...) \
.mark(...) \
.render(w=400, h=300)Coordinate Mapping
| Cartesian | Clock |
|---|---|
| x | angle (theta), 0° at top, clockwise |
| y | radius from center |
Examples
python
import math
# Pie chart
chart(data, coord=Coord.clock()) \
.flow(stack(by="category", dir="x")) \
.mark(rect(w="value", fill="category"))
# Donut chart (hollow center via inner radius)
chart(data, coord=Coord.clock(inner_radius=0.6)) \
.flow(stack(by="category", dir="x")) \
.mark(rect(w="value", fill="category"))
# Rose chart (radial bar chart)
chart(data, coord=Coord.clock()) \
.flow(spread(by="month", dir="x", spacing=0)) \
.mark(rect(w=(math.pi * 2) / 12, em_x=True, h="value"))See Also
- polar — The same transform with 0° at right, going counter-clockwise
