BUICharts

Charts/Science charts

Poincaré Map

<PoincareMap /> · 10 examples

Each value plotted against the one that follows it, so the sequence draws its own rule.

1 / 10

Starting the chart engine…

Heart rate variability

Each RR interval against the next.

Overview

Here is a cheap trick that is better than it sounds. Take a list of numbers in order. Plot the first against the second, the second against the third, the third against the fourth, and so on. A sequence that has no structure fills the plot like spilled flour. A sequence that follows any rule at all, even a messy one, lays itself along a curve or clusters into a shape. The chart is a camera that photographs the rule instead of the numbers.

The name comes from Henri Poincaré, who studied the way a system's trajectory repeatedly pierces a chosen surface, and looked at the points where it does. Plotting each return against the next is the lag-1 version of that idea. Cardiologists adopted it for heart-rate variability: plot each beat-to-beat interval against the one after it, and a healthy heart makes a comet, an arrhythmic one makes a fan, and a metronome makes a dot.

It is a remarkable amount of diagnosis for a scatter plot, and it needs no model, no units and no assumptions beyond the order matters.

Props

API

<PoincareMap data={beats} value={|b: &Beat| b.interval} label="RR" />
PropTypeDefault
datarequired
valueFn(&T) -> f64required
lagusize1
identitybool: draw the line y = xtrue
labeltext: the axes read labeln and labeln+lag"x"
colorcolourthe first series colour
point_sizef324.
tooltip, class

Plots each value against the one lag steps later. Steady signals cluster on the identity line; periodic ones form loops; chaos forms structured clouds.

Run them

10 examples

Press Run to load an example into the live render at the top of the page. Open one to read its code.

  1. 01Heart rate variabilityEach RR interval against the next.
    #[component]
    fn heart_rate() {
        let data = use_signal(heart(1));
        rsx! { <PoincareMap data={data} value={|b: &Beat| b.interval} label="RR" class="h-80" /> }
    }
  2. 02Logistic mapChaotic values trace the parabola they come from.
    #[component]
    fn chaos() {
        let data = use_signal(logistic(3.9));
        rsx! { <PoincareMap data={data} value={|b: &Beat| b.interval} point_size={3.} color={rgb(0x8839ef)} class="h-80" /> }
    }
  3. 03Lag 5Each value against the one 5 steps later.
    #[component]
    fn lagged() {
        let data = use_signal(heart(2));
        rsx! { <PoincareMap data={data} value={|b: &Beat| b.interval} lag={5} label="RR" identity={false} class="h-80" /> }
    }
  4. 04Period twoAt r = 3.2 the orbit alternates between two clusters.
    #[component]
    fn period_two() {
        let data = use_signal(logistic(3.2));
        rsx! { <PoincareMap data={data} value={|b: &Beat| b.interval} point_size={6.} color={rgb(0xd20f39)} class="h-80" /> }
    }
  5. 05Edge of chaosAt r = 3.57 the points fill a handful of tight bands.
    #[component]
    fn edge_of_chaos() {
        let data = use_signal(logistic(3.57));
        rsx! { <PoincareMap data={data} value={|b: &Beat| b.interval} point_size={3.} color={rgb(0xfe640b)} class="h-80" /> }
    }
  6. 06Chaos, lag 2The second iterate of the logistic map folds twice.
    #[component]
    fn chaos_lag_two() {
        let data = use_signal(logistic(3.9));
        rsx! { <PoincareMap data={data} value={|b: &Beat| b.interval} lag={2} point_size={3.} color={rgb(0x179299)} class="h-80" /> }
    }
  7. 07Lag 2 heart rateEach RR interval against the one two beats later.
    #[component]
    fn calm_heart() {
        let data = use_signal(heart(3));
        rsx! { <PoincareMap data={data} value={|b: &Beat| b.interval} lag={2} label="RR" color={rgb(0x40a02b)} class="h-80" /> }
    }
  8. 08Lag 10Long lags decorrelate the cloud.
    #[component]
    fn long_lag() {
        let data = use_signal(heart(4));
        rsx! { <PoincareMap data={data} value={|b: &Beat| b.interval} lag={10} label="RR" point_size={4.} class="h-80" /> }
    }
  9. 09No tooltipTooltip hidden.
    #[component]
    fn no_tooltip() {
        let data = use_signal(heart(5));
        rsx! { <PoincareMap data={data} value={|b: &Beat| b.interval} label="RR" tooltip={Tooltip::hidden()} class="h-80" /> }
    }
  10. 10Custom labelAxes named Interval with small points.
    #[component]
    fn named() {
        let data = use_signal(heart(6));
        rsx! { <PoincareMap data={data} value={|b: &Beat| b.interval} label="Interval" point_size={2.} color={rgb(0x1e66f5)} class="h-80" /> }
    }

How to read it

  1. 01Check where the cloud sits relative to the dashed diagonal. Centred on it means no trend. A systematic offset means the series is rising or falling.
  2. 02Look at its width and orientation. A tight cloud along the diagonal means each value predicts the next. A round cloud means almost no memory.
  3. 03Look for structure: a curve, two clusters, a loop, a fan. Each one is a claim about the rule behind the data.
  4. 04Hover a point to read its pair of values. Isolated points far from the cloud are single events, such as an ectopic beat, worth finding in the raw data.

When to use it, and when not to

Reach for it when

  • You have a time-ordered series and want to know in one picture whether it is steady, periodic, noisy or chaotic.
  • You are looking at heart-rate RR intervals, ECG-derived data or anything else where beat-to-beat variability matters.
  • You suspect a one-dimensional rule, such as a population model or a feedback loop, and want to see if the data lay on a curve.
  • You want to compare two recordings by the shape of their clouds, not by their means.

Skip it when

  • Order is meaningless. If you shuffle your data and it looks the same, the chart is just a scatter of a distribution with extra steps. Use a Histogram.
  • You need to see change over time. The plot discards the time axis. Slow drift looks like a smear along the diagonal.
  • Sampling is irregular. A lagged pair assumes the gap between observations is the same each time.
  • The system has several interacting variables. One lag of one variable shows only a shadow of it.

The math behind it

Lagged pairs

Take the values you extract with value in row order: x0,x1,…,xN−1x_0, x_1, \dots, x_{N-1}. For a lag kk (1 by default, and never less than 1) the chart plots the N−kN - k points below. The first coordinate is on the horizontal axis, the second on the vertical.

(xn,  xn+k),n=0,1,…,N−k−1\bigl(x_n,\; x_{n+k}\bigr), \qquad n = 0, 1, \dots, N - k - 1

The identity line

The dashed reference line is y=xy = x, drawn from the smallest to the largest finite value in the data (non-finite values are ignored when finding the range, though they are not removed from the pairs). A point on the line has xn+k=xnx_{n+k} = x_n: the sequence did not change. Above the line the next value is larger, below it smaller. Turn the line off with identity={false}.

The axis labels use the optional label, so with label RR they read RRₙ and RRₙ₊₁. The sign of xn+k−xnx_{n+k} - x_n is the one thing you can read directly from where a point sits relative to the diagonal.

What shapes mean

If the sequence is a deterministic map, xn+1=g(xn)x_{n+1} = g(x_n), then every point lies on the graph of gg and the cloud collapses to a curve. A fixed point satisfies g(x∗)=x∗g(x^{*}) = x^{*} and so sits where the curve meets the diagonal. A period-two orbit appears as two dots mirrored across the diagonal. Noise added to a map thickens the curve. Noise added to a measurement of it thickens it in a different, tilted way.

For heart-rate data two spreads are traditionally reported: the standard deviation of the points across the diagonal and along it. The chart does not compute them, and they are cheap to get from the same two columns, but the shape of the cloud is where you should look first.

SD12=12 Var(xn+1−xn),SD22=12 Var(xn+1+xn)\mathrm{SD1}^{2} = \tfrac12\,\mathrm{Var}(x_{n+1} - x_n), \qquad \mathrm{SD2}^{2} = \tfrac12\,\mathrm{Var}(x_{n+1} + x_n)

Real life usage

The marathon runner and the Tuesday ectopics

Wen was a sports physiologist who worked with a university rowing squad, which is a group of people who regard sleep as a weakness and a resting heart rate of 38 as a personality. One of them, a second-year called Ali, had started feeling flat in training and could not say why. His average resting heart rate was perfectly normal. It always is, until it is not.

The squad wore chest straps that recorded every beat interval overnight. Wen had two weeks of them for Ali, about 40,000 numbers a night, and no sensible way of reading a list of 40,000 numbers. A chart of the intervals in time looked like a seismograph that had been told to stay calm.

What she wanted was a picture where regular things would look regular and irregular things would stand out by where they landed, not how tall they were. Heart-rate researchers have a long-standing answer to that: plot each interval against the next.

She gave <PoincareMap> the interval column with label="RR" and a small point size, because there were a lot of points. A healthy night looks like a comet pointing along the diagonal. Ali's first five nights did. The sixth had two thin streaks, one above the cloud and one below it, mirrored through the diagonal.

Mirrored streaks are the signature of a premature beat: a short interval followed by a compensating long one. The sixth night had 212 such pairs, and the seventh had 340. The first thing Wen noticed was that the cloud itself had also tightened into a smaller, rounder blob, which in this context is the shape of a body under strain.

She sent Ali to a cardiologist, who found nothing alarming but a lot of stress hormones and a training load that had grown by 40 percent in a fortnight. Two lighter weeks later the streaks were gone and the comet was back. Ali complained that the chart had taken away his best excuse for a bad erg test.

Wen kept the picture on her wall. It is the only chart in her office that can tell a tired rower from a rested one without being told which is which.

Pitfalls

  • Too many points. Long recordings make a solid blob. Shrink point_size or look at a section of the record at a time.
  • Lag choice. Lag 1 shows the short-term rule. A periodic signal may only reveal itself at a lag near its period, so try several values of lag.
  • Non-finite values. NaNs are kept in the pairs, so a gap in the data becomes missing points, but the identity line is only based on the finite ones. Clean the data first if gaps are common.
  • Equal axes. Both axes share a variable but not a scale setting, so a visually perfect diagonal need not be at 45 degrees. Judge position against the dashed line, not against your sense of angle.

From around the web

Watch and read

Poincaré Maps - Dynamical Systems | Lecture 28Jason BramburgerUniversity lecture defining Poincaré maps and how they reduce a flow to a discrete map.