Skip to content
svgwind-rose

Wind rose

From which directions does it come, and how strong is it from each?

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

How to read it

  1. Read each spoke's length as the share of observations from that direction.
  2. Read colours as magnitude classes.
  3. Longer dark spokes mean frequent and strong.
  1. Callout 1: The dominant direction.
  2. Callout 2: A spoke of strong values.
  3. Callout 3: Magnitude classes.

Watch out

  • Direction is where it comes from in meteorology: check the units setting.

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 36, step 4
Magnitude classes
5
How many strength classes to colour.
Range 2 to 8, step 1
Show percentages
On
Label the rings with percentages.

Pinned in the code

  • Sectors are centred on the compass points (N covers 348.75°–11.25° with 16 sectors); length ∝ count (linear, the meteorological convention).
  • Magnitude classes have equal, rounded widths from 0 to the maximum; the last class is open-ended.
# Wind rose — Codesplash Chart Lab (recipe "wind-rose")
# controls: units=degrees, orientation=compass, bins=16, classes=5, percent=true
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap

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"]

df = pd.read_csv("wind-rose-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

_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")
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 speed_breaks(s, classes):
    """Breaks from 0 in rounded steps (1, 2, 2.5, 5, 10 × 10^k) covering the maximum."""
    mx = float(np.nanmax(s)) if len(s) else 0.0
    if not mx > 0:
        return np.array([0.0, 1.0])
    raw = mx / classes
    mag = 10 ** np.floor(np.log10(raw))
    step = next((m * mag for m in (1, 2, 2.5, 5, 10) if m * mag >= raw), raw)
    return np.round(np.arange(classes + 1) * step, 6)

def class_of(v, breaks):
    """Class index (last class open-ended)."""
    return np.clip(np.searchsorted(breaks[:-1], v, side="right") - 1, 0, len(breaks) - 2)
A = "direction"
MAG = "speed"
BINS, CLASSES, PERCENT = 16, 5, True
d = df.dropna(subset=[A, MAG])
t, s = to_turn(d[A]), d[MAG].to_numpy(float)
breaks = speed_breaks(s, CLASSES)
K = len(breaks) - 1
cls = class_of(s, breaks)
b = np.minimum(BINS - 1, np.floor(((t + 0.5 / BINS) % 1) * BINS).astype(int))  # sectors centred on the compass points
counts = np.zeros((K, BINS))
np.add.at(counts, (cls, b), 1)
n, top = len(t), counts.sum(axis=0).max() or 1
cmap = LinearSegmentedColormap.from_list("seq", SEQ)
fig, ax = plt.subplots(figsize=(6.6, 6.6), subplot_kw={"projection": "polar"})
dial(ax)
start = 2 * np.pi * (np.arange(BINS) - 0.5) / BINS
acc = np.zeros(BINS)
for k in range(K):  # magnitude classes stack outward; length = share of observations
    label = f"{breaks[k]:g}–{breaks[k + 1]:g}" if k < K - 1 else f"≥ {breaks[k]:g}"
    ax.bar(start, counts[k] / top, bottom=acc / top, width=0.92 * 2 * np.pi / BINS, align="edge", color=cmap(0.18 + 0.82 * k / max(1, K - 1)),
           edgecolor="white", linewidth=0.5, label=label)
    acc += counts[k]
fr = [0.25, 0.5, 0.75, 1]
ax.set_ylim(0, 1)
ax.set_yticks(fr, [f"{100 * round(top * f) / n:.1f}%" if PERCENT else str(round(top * f)) for f in fr], fontsize=8)
ax.legend(title=MAG, fontsize=8, loc="upper right", bbox_to_anchor=(1.22, 1.1))
plt.show()

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