RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • addpoints
    • ancestor
    • animatedline
    • area
    • axes
    • axis
    • bar
    • barh
    • box
    • caxis
    • cla
    • clf
    • clim
    • colorbar
    • colorcube
    • colormap
    • colororder
    • contour
    • contour3
    • contourf
    • copyobj
    • daspect
    • datacursormode
    • dataTipTextRow
    • errorbar
    • fcontour
    • figure
    • fill
    • fill3
    • findobj
    • fsurf
    • gca
    • gcf
    • get
    • gobjects
    • grid
    • groot
    • heatmap
    • hgload
    • hgsave
    • hidden
    • hist
    • histogram
    • histogram2
    • hold
    • image
    • imagesc
    • imshow
    • legend
    • line
    • linkaxes
    • loglog
    • mesh
    • meshc
    • openfig
    • opengl
    • pan
    • parula
    • patch
    • pie
    • plot
    • plot3
    • plotmatrix
    • plotyy
    • polarhistogram
    • polarplot
    • polarscatter
    • print
    • quiver
    • quiver3
    • ribbon
    • saveas
    • savefig
    • scatter
    • scatter3
    • semilogx
    • semilogy
    • set
    • sgtitle
    • shading
    • sphere
    • stackedplot
    • stairs
    • stem
    • subplot
    • subtitle
    • suptitle
    • surf
    • surfc
    • text
    • textscatter
    • textscatter3
    • title
    • triplot
    • view
    • waitbar
    • wordcloud
    • xlabel
    • xlim
    • xline
    • xscale
    • xtickangle
    • xtickformat
    • xticklabels
    • xticks
    • ylabel
    • ylim
    • yline
    • yscale
    • ytickangle
    • ytickformat
    • yticklabels
    • yticks
    • zlabel
    • zlim
    • zoom

plot — Create 2-D line plots in MATLAB and RunMat.

plot creates 2-D line charts from plot(y), plot(x, y), and multi-series call forms. Returned handle behavior and plotting-property integration follow MATLAB semantics.

Syntax

h = plot(Y)
h = plot(Y, LineSpec)
h = plot(Y, Name, Value, ...)
h = plot(X, Y)
h = plot(X, Y, LineSpec)
h = plot(X, Y, Name, Value, ...)
All supported plot forms
h = plot(Y)
h = plot(Y, LineSpec)
h = plot(Y, Name, Value, ...)
h = plot(X, Y)
h = plot(X, Y, LineSpec)
h = plot(X, Y, Name, Value, ...)
h = plot(ax, Y)
h = plot(ax, X, Y)
h = plot(ax, X, Y, LineSpec)
h = plot(ax, X, Y, Name, Value, ...)
h = plot(X1, Y1, ..., Xn, Yn)
h = plot(ax, X1, Y1, ..., Xn, Yn)

Inputs

NameTypeRequiredDefaultDescription
YNumericArrayYes—Y data; X defaults to 1:numel(Y).
lineSpecStyleSpecYes—Line style/color shorthand.
propsAnyVariadic—Name/value style properties.
XNumericArrayYes—X data.
YNumericArrayYes—Y data.
axAxesHandleYes—Target axes handle.
seriesAnyVariadic—Interleaved X/Y series pairs with optional per-series style tokens.

Returns

NameTypeDescription
hNumericScalarHandle to the first line object in the rendered plot series.

Errors

IdentifierWhenMessage
RunMat:plot:InvalidArgumentInput data, series grammar, axes targeting, or style arguments are invalid.plot: invalid argument
RunMat:plot:InternalInternal line construction or rendering fails unexpectedly.plot: internal operation failed

How plot works

  • plot(y) uses 1:n as the implicit x-axis, matching MATLAB shorthand behavior.
  • plot(x, y) requires the same element count in both inputs. Row and column vectors are both accepted.
  • Multiple data pairs in one call create multiple line objects and return the handle for the first created series, matching common MATLAB plotting conventions.
  • The returned handle works with get and set, so line color, width, display names, and marker properties can be inspected or updated after plotting.
  • Plotting is subplot-local. If the active axes come from subplot, the line is attached to that subplot rather than globally mutating every axes in the figure.
  • RunMat treats plot as a rendering sink: fusion stops at the builtin, but GPU residency is preserved on the happy path when the shared plotting device is installed.

Options

  • Style strings like '-', '--', ':', 'o', 'x', and combined forms such as 'r--o' are accepted in MATLAB-style plot calls, including per-series forms such as plot(x1,y1,'r',x2,y2,'b').
  • Name/value property updates can be supplied inline or applied after plotting through set(h, ...), where h is the returned line handle. Inline line-spec tokens may appear before or after name/value pairs for a series.
  • HandleVisibility accepts 'on', 'off', and 'callback'; 'off' keeps the line visible but removes it from automatic legend entries.
  • Display names set during or after plotting are used by legend when labels are not passed explicitly.

Does RunMat run plot on the GPU?

On the GPU happy path, RunMat reuses exported plot input buffers and emits renderer-ready line geometry without a full host round-trip.

Marker-heavy or otherwise unsupported combinations can fall back to host materialization while preserving the same visible result and handle semantics.

GPU memory and residency

plot preserves GPU residency when the plotting context can consume exported GPU buffers directly. If the active plotting path cannot use the input buffers, RunMat gathers once before rendering while keeping the resulting figure semantics unchanged.

Examples

Plot paired x/y data as a basic line chart

x = linspace(0, 2*pi, 200);
y = sin(x);
h = plot(x, y);

Expected output:

% h is a numeric handle for the first line object

Use MATLAB-style y-only shorthand

samples = [1 4 2 5 3];
plot(samples);

Expected output:

% RunMat uses 1:length(samples) for the x-axis

Create multiple series and drive the legend from display names

x = linspace(0, 2*pi, 200);
h1 = plot(x, sin(x));
set(h1, 'DisplayName', 'sin(x)', 'LineWidth', 2);
hold on;
h2 = plot(x, cos(x));
set(h2, 'DisplayName', 'cos(x)');
legend;

Expected output:

% The legend uses the line DisplayName properties

Use per-series LineSpec and line properties

x = 1:3;
y = [1 2 3];
plot(x, y, 'r', x, y + 1, 'b');
h = plot(x, y, 'LineWidth', 1.2, 'b', 'HandleVisibility', 'off');

Expected output:

% The first call creates red and blue series; h is visible but excluded from automatic legends

Inspect and update a plotted line through handles

x = 0:0.1:1;
h = plot(x, x.^2);
get(h, 'Type')
set(h, 'Color', 'r', 'Marker', 'o', 'MarkerSize', 6);

Expected output:

ans =
    'line'

Damped oscillation with envelope

t = linspace(0, 4*pi, 500);
envelope = exp(-0.3*t);
signal = envelope .* sin(5*t);

h1 = plot(t, signal);
set(h1, 'DisplayName', 'Damped signal', 'LineWidth', 1.5);
hold on;
h2 = plot(t, envelope, '--');
set(h2, 'DisplayName', 'Envelope', 'LineWidth', 1.5, 'Color', [0.85 0.33 0.1]);
h3 = plot(t, -envelope, '--');
set(h3, 'DisplayName', '-Envelope', 'LineWidth', 1.5, 'Color', [0.85 0.33 0.1]);
hold off;

title('Damped Oscillation');
xlabel('Time (s)');
ylabel('Amplitude');
legend;
grid on;
Expected output:
Damped oscillation with envelope

Compare this result with other chart types in the MATLAB Plot Gallery.

Using plot with coding agents

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

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

FAQ

How do I plot multiple series on the same axes?⌄

Call hold on between plot calls. Each subsequent plot adds a new line to the current axes instead of replacing the previous one.

x = linspace(0, 2*pi, 200);
plot(x, sin(x));
hold on;
plot(x, cos(x));
legend('sin', 'cos');

You can also pass multiple x/y pairs in a single plot call, e.g. plot(x, sin(x), x, cos(x)), though you lose per-series handle control that way.

What line styles and markers does plot accept?⌄

Style strings combine a color code, a line style, and a marker in any order. Line styles: '-' (solid), '--' (dashed), ':' (dotted), '-.' (dash-dot). Markers: 'o', 'x', '+', '*', 's' (square), 'd' (diamond), '^', 'v'. Colors: 'r', 'g', 'b', 'k', 'm', 'c', 'y'. For example, plot(x, y, 'r--o') draws a red dashed line with circle markers.

When should I use plot vs scatter?⌄

plot draws connected lines between points and is the right choice for continuous data or time-series. scatter draws unconnected markers and supports per-point size and color encoding through SizeData and CData. If you just want a line chart, use plot. If you need to encode a third variable via marker size or color, use scatter.

Related Plotting functions

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contour3 · contourf · mesh · meshc · plot3 · quiver · scatter3 · surf · surfc

Images

image · imagesc · imshow

Axes & Layout

axis · box · grid · sgtitle · subplot · title · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

addpoints · ancestor · animatedline · axes · barh · caxis · cla · clf · clim · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · linkaxes · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · stackedplot · subtitle · suptitle · text · textscatter · textscatter3 · triplot · waitbar · wordcloud · xlabel · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom

More plotting resources

  • Choosing the right plot type
  • Styling plots and axes
  • Plot replay and export
  • Complete plotting guide

Open-source implementation

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

  • View the source for plot 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.

Getting started · Benchmarks · Pricing

Download RunMat

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

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How plot works
  • Options
  • Does RunMat run plot on the GPU?
  • GPU memory and residency
  • Examples
  • Plot paired x/y data as a basic line chart
  • Use MATLAB-style y-only shorthand
  • Create multiple series and drive the legend from display names
  • Use per-series LineSpec and line properties
  • Inspect and update a plotted line through handles
  • Damped oscillation with envelope
  • Using plot with coding agents
  • FAQ
  • Related Plotting functions
  • 2D Charts
  • 3D & Surface
  • Images
  • Axes & Layout
  • Appearance
  • Handle Access
  • Other
  • More plotting resources
  • Open-source implementation
  • About RunMat