Skip to content
svgrose-diagram

Rose diagram

Which directions or times of day are most common?

Demo data · seed 20261101 · 66 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read petals as how many angles fall in each sector.
  2. Read petal area as frequency (radius grows as the square root).
  3. Read the arrow as the mean direction, its length as how concentrated.
  1. Callout 1: A large petal: a common direction.
  2. Callout 2: Mean direction arrow.
  3. Callout 3: Zero direction.

Watch out

  • Sector edges matter, so check other sector counts. Area-true and radius-true petals look different.

Defaults

Angles are in
Degrees
How the column measures direction; the dial is labelled to match.
Also: Radians · Hours of the day · Weekday (1 = Mon) · Month (1–12) · Day of year
Zero and direction
Top, clockwise (compass, clock)
Compass bearings and clock times start at the top and run clockwise; mathematical angles start at the right.
Also: Right, counter-clockwise (maths)
Sectors
16
How many sectors divide the circle.
Range 4 to 72, step 1
Area-true petals (√ radius)
On
Radius ∝ √count so a petal's area, not its length, is proportional to the count.
Mean direction arrow
On
Arrow toward the mean direction with length R̄ (1 = all angles identical).

Pinned in the code

  • Sector i covers [i·360/k, (i + 1)·360/k) in the chosen unit, starting at angle 0 (north, midnight, Monday, January).
  • Petal radius ∝ √count by default (area-true, Fisher 1993 §2.2); a linear radius exaggerates large counts.
  • Groups stack outward within each petal; the petal's outer edge is the sector total.
  • Arrow: mean direction θ̄ = atan2(Σ sin θ, Σ cos θ), length R̄ (the dial radius is R̄ = 1).

Use with care

Sector boundaries change the picture with few angles; compare with the circular dot plot.

# Rose diagram — Codesplash Chart Lab (recipe "rose-diagram")
# controls: units=degrees, orientation=compass, bins=16, area=true, mean=true
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import to_rgba

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
SERIES_DASHES = ["-", (0, (6, 3)), (0, (1.5, 2.5)), (0, (8, 3, 2, 3)), (0, (12, 4)), (0, (3, 3)), (0, (8, 2, 2, 2, 2, 2)), (0, (1.5, 5))]
SERIES_HATCHES = ["", "////", "..", "\\\\\\\\", "---", "xx", "|||", "++"]
HATCH_INK = to_rgba(plt.rcParams["axes.facecolor"], 0.5)  # stripes let the chart surface show through

df = pd.read_csv("rose-diagram-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["group"] = pd.Categorical(df["group"].astype("string"), categories=["control", "magnet", "anosmic"])

_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"])  # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"])  # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
def freq_levels(s, k=8):
    """Declared level order when the column is categorical, else by descending count (ties A→Z)."""
    if isinstance(s.dtype, pd.CategoricalDtype):
        return [str(v) for v in s.cat.categories][:k]
    vc = s.dropna().astype(str).value_counts()
    return sorted(vc.index, key=lambda v: (-vc[v], v))[:k]
UNITS, COMPASS = "degrees", True  # compass: 0 at the top, clockwise; else 0 at the right, counter-clockwise
PERIOD, ORIGIN = 360, 0  # one full turn, and the value at angle 0
TICK_T = [0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875]
TICK_LABELS = ["0°", "45°", "90°", "135°", "180°", "225°", "270°", "315°"]
def to_turn(v):
    return np.mod((np.asarray(v, dtype=float) - ORIGIN) / PERIOD, 1.0)
def dial(ax):
    ax.set_theta_zero_location("N" if COMPASS else "E")
    ax.set_theta_direction(-1 if COMPASS else 1)
    ax.set_xticks([2 * np.pi * t for t in TICK_T], TICK_LABELS)
    ax.grid(True, linewidth=0.5, alpha=0.6)
def circ_stats(t):
    C, S = np.cos(2 * np.pi * t).sum(), np.sin(2 * np.pi * t).sum()
    n = len(t)
    return (np.arctan2(S, C) / (2 * np.pi)) % 1, (np.hypot(C, S) / n if n else np.nan)
def grouped_turns(df, A, G, k):
    d = df.dropna(subset=[A])
    if not G:
        return [("", to_turn(d[A]))]
    return [(g, to_turn(d.loc[d[G].astype(str) == g, A])) for g in freq_levels(d[G], k)]
A = "bearing"
G = "group"
BINS, AREA, MEAN = 16, True, True  # area-true petals: radius ∝ √count
groups = grouped_turns(df, A, G, 8)
counts = np.array([np.bincount(np.minimum(BINS - 1, np.floor(t * BINS).astype(int)), minlength=BINS) for _, t in groups], dtype=float)  # sector i = [i/BINS, (i+1)/BINS)
top = counts.sum(axis=0).max() or 1
radius = (lambda n: np.sqrt(n / top)) if AREA else (lambda n: n / top)
fig, ax = plt.subplots(figsize=(6.4, 6.4), subplot_kw={"projection": "polar"})
dial(ax)
acc = np.zeros(BINS)
for i, (name, _) in enumerate(groups):  # groups stack outward within a petal
    r0, r1 = radius(acc), radius(acc + counts[i])
    ax.bar(2 * np.pi * np.arange(BINS) / BINS, r1 - r0, bottom=r0, width=2 * np.pi / BINS, align="edge", color=PALETTE[i % len(PALETTE)],
           edgecolor="white", linewidth=0.5, hatch=SERIES_HATCHES[i % 8] if G else "", hatchcolor=HATCH_INK, label=name or None)  # texture per group, as in the app
    acc += counts[i]
if MEAN:  # arrow toward the mean direction, length R̄
    for i, (name, t) in enumerate(groups):
        mu, rbar = circ_stats(t)
        ax.annotate("", xy=(2 * np.pi * mu, rbar), xytext=(0, 0), arrowprops=dict(arrowstyle="-|>", color=PALETTE[i % len(PALETTE)] if G else REF, lw=1.8, linestyle=SERIES_DASHES[i % 8] if G else "-"))  # dash per group
fr = [0.25, 0.5, 0.75, 1]
ax.set_ylim(0, 1)
ax.set_yticks(fr, [str(round(top * f * f)) if AREA else str(round(top * f)) for f in fr], fontsize=8)  # ring labels are counts
if G:
    ax.legend(fontsize=8, loc="upper right", bbox_to_anchor=(1.18, 1.1))
plt.show()

Needs pandas, numpy, matplotlib · reads rose-diagram-demo.csv · app theme from the optional codesplash helper