RunMat
GitHub

View all functions

CategoryPlotting
GPUYes

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 x and y must 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 plot append to the current figure when users call hold 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