plotly/plotly.js · error

Invalid input - make sure that q1 <= median <= q3 q1 = <cdi.

Error message

Invalid input - make sure that q1 <= median <= q3
q1 = <cdi.q1>
median = <cdi.med>
q3 = <cdi.q3>

What it means

Data-integrity check in box trace calc when trace.notched is true. Notches are computed around the median using q1, median and q3 (possibly user-supplied via precomputed statistics q1/med/q3); the notch geometry is only well defined if q1 <= median <= q3. The throw fires when the supplied quartile/median values violate that ordering — e.g. swapped or mistyped q1/q3 in precomputed box stats — making the box/nonchspan invalid.

Source

Thrown at src/traces/box/calc.js:145

                var ns = d2c('notchspan');
                ns = (ns !== BADNUM && ns > 0) ? ns : computeNotchSpan(cdi, N);
                cdi.ln = cdi.med - ns;
                cdi.un = cdi.med + ns;

                var imin = cdi.lf;
                var imax = cdi.uf;
                if(trace.boxpoints && boxVals.length) {
                    imin = Math.min(imin, boxVals[0]);
                    imax = Math.max(imax, boxVals[N - 1]);
                }
                if(trace.notched) {
                    imin = Math.min(imin, cdi.ln);
                    imax = Math.max(imax, cdi.un);
                }
                cdi.min = imin;
                cdi.max = imax;
            } else {
                Lib.warn([
                    'Invalid input - make sure that q1 <= median <= q3',
                    'q1 = ' + cdi.q1,
                    'median = ' + cdi.med,
                    'q3 = ' + cdi.q3
                ].join('\n'));

                var v0;
                if(cdi.med !== BADNUM) {
                    v0 = cdi.med;
                } else if(cdi.q1 !== BADNUM) {
                    if(cdi.q3 !== BADNUM) v0 = (cdi.q1 + cdi.q3) / 2;
                    else v0 = cdi.q1;
                } else if(cdi.q3 !== BADNUM) {
                    v0 = cdi.q3;
                } else {
                    v0 = 0;
                }

View on GitHub (pinned to 1d090e0b5f)

Solutions

  1. Check precomputed q1/med/q3 values for the offending point and correct their order.
  2. If computing quartiles yourself, use a consistent method so q1 <= median <= q3 holds.
  3. Disable notches (notched: false) if the data cannot satisfy the invariant.
  4. Validate the input array passed to the box trace's precomputed statistics (q1/median/q3 fields).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/traces/box/calc.js:145 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of plotly/plotly.js@1d090e0b5f (2026-09-02). Data as JSON: /api/errors/ce57275c56b0cda2. Report an issue: GitHub.