14 Polar Coordinates
For polar coordinates, (sk/coord :polar) maps x to angle and y to radius. Bars become arc-interpolated wedges (rose charts), and scatter points wrap into a disc. Currently best suited for point and bar-family marks.
(ns napkinsketch-book.polar
(:require
;; Shared datasets for these docs
[napkinsketch-book.datasets :as data]
;; Kindly β notebook rendering protocol
[scicloj.kindly.v4.kind :as kind]
;; Napkinsketch β composable plotting
[scicloj.napkinsketch.api :as sk]))(def wind {:direction ["N" "NE" "E" "SE" "S" "SW" "W" "NW"]
:speed [12 8 15 10 7 13 9 11]})Polar Scatter
The same scatter plot, wrapped into polar space. x maps to angle (clockwise from 12 oβclock), y maps to radius (center = minimum, edge = maximum).
(-> data/iris
(sk/lay-point :sepal_length :sepal_width {:color :species})
(sk/coord :polar))Rose Chart (Coxcomb Diagram)
A bar chart in polar coordinates produces a rose chart β wedge area encodes count. Bars are arc-interpolated for smooth curved edges.
(-> data/iris
(sk/lay-bar :species)
(sk/coord :polar))Wind Rose
A value-bar chart in polar makes a wind rose β each direction gets a wedge proportional to wind speed.
(-> wind
(sk/lay-value-bar :direction :speed)
(sk/coord :polar))Polar Stacked Bar
Stacked bars in polar show composition within each wedge.
(-> data/penguins
(sk/lay-stacked-bar :island {:color :species})
(sk/coord :polar))Polar Histogram
A histogram in polar wraps bins around the circle. Useful for circular distributions (e.g., time of day, compass bearing).
(-> data/iris
(sk/lay-histogram :sepal_length)
(sk/coord :polar))Explicit Labels with Polar
By default, polar suppresses auto-generated axis labels (since there are no rectangular axes). You can still set a title with sk/options:
(-> data/iris
(sk/lay-point :sepal_length :sepal_width {:color :species})
(sk/coord :polar)
(sk/options {:title "Iris in Polar Space"}))Whatβs Next
- Cookbook β recipes for common multi-layer plots
- Customization β colors, annotations, and interactive features