plot3 — Create 3-D line plots for trajectories, parametric curves, and spatial paths with MATLAB plot3 semantics.
plot3 creates line plots in 3-D space from matching x, y, and z inputs. In RunMat it returns a line3 handle, participates in the graphics-object system, and supports both host and GPU-backed inputs through the dedicated 3-D line pipeline.
How plot3 works in RunMat
plot3(x, y, z)requires matching element counts in all three inputs.- The builtin returns a 3-D line handle that can be inspected and updated through
getandset. - Multiple 3-D series in one call create multiple line objects and return the handle for the first created series.
plot3is camera-aware and naturally pairs withviewandzlabelin the subplot-local 3-D state model.- GPU-backed 3-D line rendering is used when the shared plotting device can consume exported buffers directly.
How plot3 runs on the GPU
The dedicated 3-D line pipeline is separate from 2-D plot, which keeps camera-aware rendering and bounds handling explicit.
Subview state, labels, and line object behavior remain identical across GPU and host fallback paths.
GPU memory and residency
plot3 preserves GPU residency when the 3-D line pipeline can consume exported coordinate buffers directly. Fallback rendering gathers once while preserving the same handle and axes semantics.
Examples
Create a 3-D helix
t = linspace(0, 6*pi, 300);
plot3(cos(t), sin(t), t);Plot multiple 3-D trajectories and label them
t = linspace(0, 4*pi, 200);
h1 = plot3(cos(t), sin(t), t);
set(h1, 'DisplayName', 'helix A');
hold on;
h2 = plot3(cos(t), sin(t), -t);
set(h2, 'DisplayName', 'helix B');
legend;Control the camera and z-axis after plotting
t = linspace(0, 4*pi, 150);
h = plot3(cos(t), sin(t), t);
zlabel('Height');
view(45, 20);
get(h, 'Type')Expected output:
ans =
'line'Related functions to explore
These functions work well alongside plot3. Each page has runnable examples you can try in the browser.
scatter3, view, zlabel, legend
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how plot3 works, line by line, in Rust.
- View plot3.rs on GitHub
- Learn how the 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 — faster, on any GPU, with no license required.
- Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
- Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
- A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.