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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Z | NumericArray | Yes | — | Arrow base z-coordinates. |
U | NumericArray | Yes | — | Vector field x-components. |
V | NumericArray | Yes | — | Vector field y-components. |
W | NumericArray | Yes | — | Vector field z-components. |
X | NumericArray | Yes | — | Arrow base x-coordinates. |
Y | NumericArray | Yes | — | Arrow base y-coordinates. |
args | Any | Variadic | — | Optional scale, line-style shorthand, or name/value style arguments. |
ax | AxesHandle | Yes | — | Target axes handle. |
Returns
| Name | Type | Description |
|---|---|---|
h | NumericScalar | Handle to the rendered 3-D quiver plot. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:quiver3:InvalidArgument | Input data, axes targeting, scale, or style arguments are invalid. | quiver3: invalid argument |
RunMat:quiver3:Internal | Internal 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 ofZ.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
getand style updates throughset. - 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.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · axes · barh · cla · clf · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · linkaxes · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · ribbon · saveas · savefig · sphere · stackedplot · subtitle · suptitle · textscatter · textscatter3 · triplot · waitbar · wordcloud · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zoom
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.
- View the source for quiver3 in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
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.