plot — Draw 2-D line plots that mirror MATLAB's plot(x, y) semantics.
plot(x, y) creates a 2-D line plot with MATLAB-compatible styling. Inputs may be real row/column vectors or single-precision gpuArray vectors when a shared WebGPU context is available.
How does the plot function behave in MATLAB / RunMat?
- Both
xandymust contain the same number of elements; mismatched lengths raise errors. - Default styling mirrors MATLAB: blue solid line with circular markers disabled. Line width matches MATLAB's default (approx. 1 pt) but can be adjusted once the interactive window is open.
- Multiple calls to
plotappend to the current figure when users callhold on(future work). - Single-precision gpuArray vectors stay on the device and feed a zero-copy line packer. Double-precision data or dashed/marker-heavy styles fall back to the CPU path automatically.
GPU residency
plot terminates fusion graphs. If the inputs are single gpuArrays and the shared plotter device is active, their buffers are consumed zero-copy by the renderer. Otherwise the tensors are gathered before plotting, matching MATLAB semantics.
Example of using plot in MATLAB / RunMat
plot(0:0.1:2*pi, sin(0:0.1:2*pi));
plot(time, amplitude)Source & Feedback
- Source code: `crates/runmat-runtime/src/builtins/plotting/ops/plot.rs`
- Found a bug? Open an issue with a minimal reproduction.