Skip to main content

Rose chart

A Nightingale rose (a coxcomb chart) is a polar bar chart: one sector per category, with the sector's area or radius proportional to its value. Florence Nightingale's famous mortality diagram is the canonical example, and it remains the standard form for a wind rose.

SELECT kuva_render(to_json({
'title': 'Wind by direction',
'series': [{
'type': 'rose',
'slices': slices,
'show_values': true
}]
})) AS chart
FROM (
SELECT list({'label': direction, 'value': low_speed} ORDER BY direction) AS slices
FROM read_csv_auto('{{DFK_BASE_URL}}data/rose.tsv')
);

Sectors start at twelve o'clock and run clockwise by default, in list order.

Bearing data​

Wind roses usually start as raw measurements — one compass bearing per observation — and counting them into sectors is the tedious part. Hand over the bearings and how many sectors you want, and kuva does the binning:

SELECT kuva_render(to_json({
'title': 'Wind rose from raw bearings',
'series': [{
'type': 'rose',
'bearings': [10, 45, 90, 135, 180, 225, 270, 315, 355],
'bearings_bins': 8,
'compass_labels': true,
'color': '#4c72b0'
}]
})) AS chart;

Every bearing is folded into 0–360°, dropped into one of bearings_bins equal sectors, and the sector values become the counts — "how many observations came from each direction", with no GROUP BY in sight.

Stacked mode​

Several series stacked inside each sector — the natural layout for a wind rose, where each sector is a direction and each band a speed class:

WITH d AS (SELECT * FROM read_csv_auto('{{DFK_BASE_URL}}data/rose.tsv'))
SELECT kuva_render(to_json({
'title': 'Wind rose',
'series': [{
'type': 'rose',
'labels': (SELECT list(direction ORDER BY direction) FROM d),
'series': [
{'name': 'low speed', 'values': (SELECT list(low_speed ORDER BY direction) FROM d)},
{'name': 'high speed', 'values': (SELECT list(high_speed ORDER BY direction) FROM d)}
],
'mode': 'stacked',
'legend': 'speed'
}]
})) AS chart;

Grouped mode​

"mode": "grouped" gives each series its own sub-wedge inside every sector instead of stacking them. That is what you want when the series are alternatives rather than parts of a whole — products in a quarter rather than speed classes in a direction.

WITH d AS (SELECT * FROM read_csv_auto('{{DFK_BASE_URL}}data/rose.tsv'))
SELECT kuva_render(to_json({
'title': 'Grouped rose',
'series': [{
'type': 'rose',
'labels': (SELECT list(direction ORDER BY direction) FROM d),
'series': [
{'name': 'low speed', 'values': (SELECT list(low_speed ORDER BY direction) FROM d)},
{'name': 'high speed', 'values': (SELECT list(high_speed ORDER BY direction) FROM d)}
],
'mode': 'grouped',
'legend': 'speed'
}]
})) AS chart;

Encoding​

encodingRadius
"area"The sector's area is proportional to the value (default)
"radius"The sector's radius is proportional to the value

Area is the perceptually honest choice, and it is why the default is not the obvious one: encoding a value in a radius squares it, so a sector twice as large as another reads as four times the value.

SELECT kuva_render(to_json({
'title': 'Radius encoding',
'series': [{
'type': 'rose',
'slices': slices,
'encoding': 'radius',
'show_values': true
}]
})) AS chart
FROM (
SELECT list({'label': direction, 'value': low_speed} ORDER BY direction) AS slices
FROM read_csv_auto('{{DFK_BASE_URL}}data/rose.tsv')
);

Compass labels​

compass_labels renames the sectors with the cardinal and intercardinal directions implied by how many there are — N, NE, E, … for 8 sectors, N, E, S, W for 4. A count that is not a divisor of 16 falls back to degree labels, so nothing breaks; it just reads less like a compass.

SELECT kuva_render(to_json({
'title': 'Four sectors, four names',
'series': [{
'type': 'rose',
'bearings': [10, 45, 90, 135, 180, 225, 270, 315, 355],
'bearings_bins': 4,
'compass_labels': true,
'show_values': true
}]
})) AS chart;

Inner radius​

inner_radius is a fraction of the outer radius (clamped to 0–0.95), which turns the rose into a donut and leaves the middle for a label or a total.

SELECT kuva_render(to_json({
'title': 'Donut rose',
'series': [{
'type': 'rose',
'slices': slices,
'inner_radius': 0.3,
'show_values': true
}]
})) AS chart
FROM (
SELECT list({'label': direction, 'value': low_speed} ORDER BY direction) AS slices
FROM read_csv_auto('{{DFK_BASE_URL}}data/rose.tsv')
);

Grid, spokes and labels​

FieldDefaultWhat it sets
show_gridtrueConcentric grid rings
grid_lines4How many rings
show_spokestrueRadial lines at the sector boundaries
show_labelstrueCategory labels around the perimeter
show_valuesfalseValue labels at the sector tips
gap1Angular gap between sectors, in degrees
start_angle0Where sector 0 begins (degrees clockwise from north)
clockwisetrueDirection the sectors are laid out

Fields​

FieldTypeWhat it sets
slicesslice[]Single-series form: {label, value, color?} per sector.
labelsstring[]Sector names around the circumference.
seriesseries[]Multi-series form: {name, values, color?}; replaces slices.
bearingsnumber[]Raw compass bearings (0–360°) to bin; replaces slices / series.
bearings_binsintegerHow many sectors to bin the bearings into (with bearings).
compass_labelsbooleanRename the sectors N, NE, E, … .
colorstringColour for the sectors or series that do not set their own.
encodingstring"area" (default) or "radius".
modestring"stacked" (default) or "grouped".
inner_radiusnumberDonut hole as a fraction of the outer radius.
gapnumberAngular gap between sectors, in degrees.
start_anglenumberStart angle, in degrees.
clockwisebooleanLay the sectors out clockwise (default on).
show_grid / grid_linesboolean / integerThe concentric rings.
show_spokesbooleanThe radial boundary lines.
show_labels / show_valuesbooleanPerimeter names and tip values.
legendstringLegend title; one entry per series.

Notes​

  • slices, series and bearings are three ways to give the same data — give exactly one.
  • In multi-series mode every series needs one value per label, in the same order.
  • bearings needs bearings_bins; bearings_bins on its own is rejected, and 0 bins is rejected too (binning into nothing produces an empty chart rather than an error, so it is caught here).
  • compass_labels works in all three forms and overwrites the names: it derives them from the sector count, so there is no point passing labels and compass_labels together.
  • encoding: "radius" exaggerates large sectors by design; it is a deliberate choice, not a neutral one.

See also​