Vector Fields, Quiver Plots, and Streamlines: A New Way to See Direction and Magnitude in CanvasXpress

Some data doesn't just have a position — it has momentum. A cell moving through gene-expression space, a particle drifting across a fluid simulation, a gradient pointing toward a local optimum: in every one of these cases, the story isn't just "where is this point," but "where is it going, and how fast." Scatter plots are great at the first question and silent on the second.

CanvasXpress now closes that gap with Vector Field Plots — a Scatter2D-based capability that draws direction and magnitude directly on top of your coordinate data, in three increasingly abstracted forms: per-point arrows, a gridded quiver field, and continuous streamlines.

Why build this on Scatter2D?

A vector field is, at its core, a 2D numeric coordinate space where every point carries an extra direction-and-magnitude payload. That's exactly the data model Scatter2D already understands — so rather than invent a new graph type from scratch, CanvasXpress extends Scatter2D with a dedicated vector-field mode. The payoff is that you inherit everything Scatter2D already does well: axis scaling, zoom and pan, tooltips, group coloring, and legends, all for free. You're not learning a new chart type — you're turning on a new rendering mode for a chart type you probably already use.

Three modes, one dataset

Give CanvasXpress a table with position columns (x, y) and vector columns (vx, vy) — optionally alongside a group annotation — and you can render it three ways:

All three modes read from the same underlying shape, so switching between "show me every cell's velocity" and "show me the overall flow" is a configuration change, not a data-wrangling exercise.

Turning it on

Vector field rendering is opt-in: it sits behind a scatterType setting on a standard Scatter2D chart, so none of your existing scatter plots change behavior. A minimal setup looks like this:

var cx = new CanvasXpress("chartCanvas", data, {
  graphType: "Scatter2D",
  scatterType: "vectorfield",
  vectorFieldMode: "grid",
  vectorXBy: "x",
  vectorYBy: "y",
  vectorUBy: "vx",
  vectorVBy: "vy",
  vectorColorByMagnitude: true,
  vectorShowLegend: true
});

Switch vectorFieldMode to "raw" for per-sample arrows or "stream" for streamlines, and the same data drives a completely different visual story. Because this is just configuration, you can also toggle modes on an already-rendered chart by calling updateConfig with the new vectorFieldMode and redrawing — handy for building an interactive "raw vs. grid vs. stream" toggle in a dashboard.

Dialing in the look

Vector Field Plots expose a set of controls tuned to each mode: vectorScale and vectorArrowSize control arrow length and head size; vectorGridSize sets quiver/streamline grid resolution; vectorDensity thins out dense raw-arrow fields so individual vectors stay legible; vectorMinMagnitude filters out near-zero noise; and vectorGroupBy lets raw arrows inherit group coloring (say, cell type) instead of magnitude coloring. For streamlines specifically, streamlineColor, streamlineSteps, streamlineStepSize, and streamlineSeedStride give you control over how far streamlines travel and how densely they're seeded — trade a few extra lines for finer flow detail, or pull back for a cleaner overview. A built-in legend (vectorShowLegend) ties magnitude or group coloring back to a readable key or colorbar, so viewers aren't left guessing what color means.

Where this shines

The motivating use case is RNA velocity — the single-cell genomics technique that overlays predicted future cell states as vectors on a 2D embedding (UMAP, t-SNE, PCA). Until now, visualizing that output meant stepping outside the library; now it's a native chart configuration, complete with group coloring by cell type and magnitude-based emphasis on fast-transitioning cells.

But the capability isn't limited to biology. Any dataset with a position-plus-direction structure benefits: wind and ocean current fields, electromagnetic or gravitational field visualizations, optimization trajectories across a loss surface, or flow fields in simulations. If you've ever reached for matplotlib's quiver or streamplot to make sense of directional data, you now have a native equivalent inside your CanvasXpress workflow — with the same interactivity (zoom, pan, tooltips) your other charts already have.

Sharing your work

Once you've built a vector field chart you like, it behaves like any other CanvasXpress visualization for collaboration: use Save as JSON from the chart's File menu to serialize the exact chart — data, configuration, and all — and share the resulting file. Anyone can reload it by dragging that .json file onto a CanvasXpress container, and the Reproduce toolbar action lets you (or a teammate) replay exactly how the chart was built, step by step — useful for teaching the technique or auditing how a particular streamline or quiver configuration was produced.

Vector Field Plots round out CanvasXpress's scatter family with a capability that used to require a separate plotting library: direction and magnitude, rendered natively, at three levels of visual abstraction, on the same chart engine you already know.