Skip to content

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, rect, clock

chart(seafood, coord=clock()) \
    .flow(stack(by="species", dir="x")) \
    .mark(rect(w="count", fill="species")) \
    .render(w=400, h=300)

Signature ​

python
clock(
    inner_radius: float | None = None,
    central_angle: float | None = None,
    start_angle: float | None = None,
    direction: int | None = None,
    center: tuple[float, float] | None = None,
) -> Coord

Parameters ​

A polar() preset (0° at 12 o'clock, clockwise — already polar's defaults) kept as a distinct type tag for bbox sampling and user intent.

OptionTypeDefaultDescription
inner_radiusfloat0Donut hole as a fraction [0,1) of the outer radius.
central_anglefloat2πTotal angular sweep in radians.
start_anglefloatπ/2Angle (radians) of θ=0.
directionfloat-1+1 counter-clockwise, -1 clockwise (numeric ±1).
centertuple[0, 0]Screen-space center offset.

clock() is a polar() preset and accepts the same options — inner_radius, central_angle, start_angle, direction, center — but with clock-face defaults (0° at 12 o'clock, clockwise). See polar's Parameters.

Usage ​

Pass the coordinate transform to chart via the coord keyword:

python
chart(data, coord=clock()) \
    .flow(...) \
    .mark(...) \
    .render(w=400, h=300)

Coordinate Mapping ​

CartesianClock
xangle (theta), 0° at top, clockwise
yradius from center

Examples ​

python
import math

# Pie chart
chart(data, coord=clock()) \
    .flow(stack(by="category", dir="x")) \
    .mark(rect(w="value", fill="category"))

# Donut chart (hollow center via inner radius)
chart(data, 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=clock()) \
    .flow(stack(by="month", dir="x")) \
    .mark(rect(w=(math.pi * 2) / 12, em_x=True, h="value"))

See Also ​

  • polar — Standard polar coordinates with 0° at right