plotly/plotly.js · warning
Encountered arbitrary coordinates! Unable to input data grid
Error message
Encountered arbitrary coordinates! Unable to input data grid.
What it means
processGrid in src/traces/streamtube/calc.js:206 validates that x/y/z coordinates form a regular (grid) mesh. When coordinates are 'arbitrary' — not evenly spaced / not a cartesian product along each axis — the streamtube algorithm cannot build the vector-field grid, so Plotly warns and empties the trace (empty()), rendering nothing.
Source
Thrown at src/traces/streamtube/calc.js:206
var q100 = getIndex(i + 1, j, k);
if(
!(arrK[q000] * dirK < arrK[q001] * dirK) ||
!(arrJ[q000] * dirJ < arrJ[q010] * dirJ) ||
!(arrI[q000] * dirI < arrI[q100] * dirI)
) {
arbitrary = true;
}
if(arbitrary) break;
}
if(arbitrary) break;
}
if(arbitrary) break;
}
if(arbitrary) {
Lib.warn('Encountered arbitrary coordinates! Unable to input data grid.');
empty();
}
return {
xMin: xMin,
yMin: yMin,
zMin: zMin,
xMax: xMax,
yMax: yMax,
zMax: zMax,
Xs: Xs,
Ys: Ys,
Zs: Zs,
len: len,
fill: gridFill
};
}
View on GitHub (pinned to 1d090e0b5f)
Solutions
- Resample your data onto a regular, monotonically increasing grid before plotting.
- Use numpy/meshgrid (or the JS equivalent) to build x/y/z from linspace ranges matching the u/v/w array shapes.
- If the data is inherently scattered, visualize with scatter3d instead of streamtube.
Example fix
// before x: [0, 0.3, 1], y: [0, 0.7, 1], z: [0, 0.5, 1] // irregular spacing // after x: [0, 0.5, 1], y: [0, 0.5, 1], z: [0, 0.5, 1] // uniform grid
Defensive patterns
Strategy: validation
Validate before calling
function isUniformAndIncreasing(arr, eps = 1e-9) {
const d = arr[1] - arr[0];
if (d <= eps) return false;
return arr.every((v, i) => i === 0 || Math.abs((arr[i] - arr[i - 1]) - d) < eps);
}
if (!isUniformAndIncreasing(x) || !isUniformAndIncreasing(y) || !isUniformAndIncreasing(z)) {
throw new Error('streamtube requires uniformly spaced, increasing x/y/z grids');
} Type guard
function isRegularGrid(x, y, z) {
const inc = a => a.every((v, i) => i === 0 || v > a[i - 1]);
return inc(x) && inc(y) && inc(z) &&
u.length === x.length * y.length * z.length;
} Prevention
- Always build streamtube coordinates with linspace/meshgrid-style helpers.
- Resample irregular measurement data to a regular grid before plotting.
- Use scatter3d for scattered data instead of forcing it into streamtube.
When it happens
Trigger: A streamtube trace whose x, y or z arrays are not strictly increasing with uniform spacing, or whose lengths do not correspond to a rectangular grid of u/v/w samples (e.g. scattered measurement points instead of a mesh).
Common situations: Feeding raw CFD/experimental sensor data collected at irregular positions; generating coordinates from simulation output on unstructured meshes; typos causing duplicate or out-of-order coordinates.
AI-assisted analysis of plotly/plotly.js@1d090e0b5f (2026-09-02).
Data as JSON: /api/errors/b88d1796e825b006.
Report an issue: GitHub.