quiver3 — Visualize 3-D vector fields with MATLAB-compatible quiver3 plots.

quiver3 draws arrows anchored at 3-D coordinates and returns a graphics handle. It supports implicit grid coordinates from Z, explicit X, Y, and Z coordinates, axes targeting, numeric scale factors, line-style shorthand, and name/value styling.

Syntax

h = quiver3(Z, U, V, W)
h = quiver3(X, Y, Z, U, V, W)
h = quiver3(Z, U, V, W, scaleOrStyleOrNameValue...)
h = quiver3(X, Y, Z, U, V, W, scaleOrStyleOrNameValue...)
h = quiver3(ax, Z, U, V, W)
h = quiver3(ax, X, Y, Z, U, V, W)
h = quiver3(ax, Z, U, V, W, scaleOrStyleOrNameValue...)
h = quiver3(ax, X, Y, Z, U, V, W, scaleOrStyleOrNameValue...)

Inputs

NameTypeRequiredDefaultDescription
ZNumericArrayYesArrow base z-coordinates.
UNumericArrayYesVector field x-components.
VNumericArrayYesVector field y-components.
WNumericArrayYesVector field z-components.
XNumericArrayYesArrow base x-coordinates.
YNumericArrayYesArrow base y-coordinates.
argsAnyVariadicOptional scale, line-style shorthand, or name/value style arguments.
axAxesHandleYesTarget axes handle.

Returns

NameTypeDescription
hNumericScalarHandle to the rendered 3-D quiver plot.

Errors

IdentifierWhenMessage
RunMat:quiver3:InvalidArgumentInput data, axes targeting, scale, or style arguments are invalid.quiver3: invalid argument
RunMat:quiver3:InternalInternal quiver3 construction or rendering fails unexpectedly.quiver3: internal operation failed

How quiver3 works

  • quiver3(Z, U, V, W) builds default X/Y grid coordinates from the shape of Z.
  • quiver3(X, Y, Z, U, V, W) accepts matching coordinate arrays or meshgrid-style X/Y vectors for matrix vector fields.
  • The returned graphics handle exposes XData, YData, ZData, UData, VData, WData, Color, LineWidth, AutoScaleFactor, MaxHeadSize, Parent, Children, and Type through get and style updates through set.
  • 3-D arrow geometry is stored in the shared quiver plot primitive, so replay/export preserves Z/W data and 3-D bounds.
  • Changing scale, head size, color, or data properties invalidates cached quiver geometry before the next render.

Options

  • A numeric argument after the vector data controls the arrow scale factor.
  • 'AutoScaleFactor' / 'Scale' controls arrow scaling.
  • 'MaxHeadSize' / 'HeadSize' controls the size of arrowheads.
  • Line-style color and width workflows use the same parser as other line-like plotting builtins.

Does RunMat run quiver3 on the GPU?

Host and GPU-fallback paths produce the same handle semantics and replay/export data.

A future direct WGPU path should mirror the existing 2-D quiver GPU packer with Z/W coordinate buffers.

GPU memory and residency

quiver3 is currently a gather-immediate plotting sink. GPU-resident inputs are materialized once before building 3-D arrow geometry; direct provider-backed geometry emission is intentionally left to the queued GPU fast-path audit.

Examples

Create a 3-D vector field from Z and vector components

[X, Y] = meshgrid(-2:1:2, -2:1:2);
Z = X.^2 - Y.^2;
U = -Y;
V = X;
W = ones(size(Z));
quiver3(Z, U, V, W);

Provide explicit coordinates and style the arrows

[X, Y, Z] = meshgrid(-1:1, -1:1, 0:1);
U = -Y;
V = X;
W = 0.5 * ones(size(Z));
h = quiver3(X, Y, Z, U, V, W, 1.5, 'r');
set(h, 'DisplayName', 'flow', 'MaxHeadSize', 0.2);
view(45, 30);

Target a specific axes

ax = axes;
quiver3(ax, 1:3, 1:3, 1:3, [1 0 -1], [0 1 0], [0 0 1]);

Using quiver3 with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how quiver3 changes the result.

Run a small quiver3 example, explain the result, then change one input and compare the output.

FAQ

How do I control arrow lengths in a quiver3 plot?

Pass a numeric scale after the vector data or set the 'AutoScaleFactor' property.

h = quiver3(X, Y, Z, U, V, W, 0.75);
set(h, 'AutoScaleFactor', 1.5);
Can I inspect the 3-D vector data after plotting?

Yes. Use get(h, 'XData'), get(h, 'YData'), get(h, 'ZData'), get(h, 'UData'), get(h, 'VData'), and get(h, 'WData') on the returned handle.

Does quiver3 keep GPU data resident?

Not yet on the direct geometry path. RunMat gathers GPU inputs once and preserves the same plotting and handle semantics; direct WGPU packing for 3-D arrows is tracked by the eval-loop GPU fast-path audit.

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how quiver3 is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.