RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

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.

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

stem — Create stem plots for discrete sequences with MATLAB-compatible stem syntax and styling controls.

stem draws discrete samples as vertical lines from a baseline and returns a graphics handle. Pass Y alone for one-based x coordinates or paired X,Y data for explicit positions. X and Y may use single, double, or any of the eight integer classes. RunMat retains the native source class for property queries and figure persistence while deriving floating geometry for display.

Syntax

h = stem(Y)
h = stem(Y, LineSpec)
h = stem(Y, Name, Value, ...)
h = stem(X, Y)
h = stem(X, Y, LineSpec)
h = stem(X, Y, Name, Value, ...)
All supported stem forms
h = stem(Y)
h = stem(Y, LineSpec)
h = stem(Y, Name, Value, ...)
h = stem(X, Y)
h = stem(X, Y, LineSpec)
h = stem(X, Y, Name, Value, ...)
h = stem(ax, Y)
h = stem(ax, Y, LineSpec)
h = stem(ax, Y, Name, Value, ...)
h = stem(ax, X, Y)
h = stem(ax, X, Y, LineSpec)
h = stem(ax, X, Y, Name, Value, ...)

Inputs

Y
Type
NumericArray
Required
Yes
Description
Y samples. X defaults to 1:numel(Y).
lineSpec
Type
StyleSpec
Required
Yes
Description
Line style shorthand such as '--r'.
props
Type
Any
Required
Variadic
Description
Name/value style properties.
X
Type
NumericArray
Required
Yes
Description
X samples.
Y
Type
NumericArray
Required
Yes
Description
Y samples.
ax
Type
AxesHandle
Required
Yes
Description
Target axes handle.
NameTypeRequiredDefaultDescription
YNumericArrayYes—Y samples. X defaults to 1:numel(Y).
lineSpecStyleSpecYes—Line style shorthand such as '--r'.
propsAnyVariadic—Name/value style properties.
XNumericArrayYes—X samples.
YNumericArrayYes—Y samples.
axAxesHandleYes—Target axes handle.

Returns

h
Type
NumericScalar
Description
Handle to the rendered stem plot.
NameTypeDescription
hNumericScalarHandle to the rendered stem plot.

Errors

RunMat:stem:InvalidArgument
When
Input data, axes targeting, or style arguments are invalid.
Message
stem: invalid argument
RunMat:stem:Internal
When
Internal plot construction or rendering fails unexpectedly.
Message
stem: internal operation failed
RunMat:plotting:TooManyOutputs
When
More than one output is requested from a coordinate chart constructor.
Message
plotting: too many output arguments
IdentifierWhenMessage
RunMat:stem:InvalidArgumentInput data, axes targeting, or style arguments are invalid.stem: invalid argument
RunMat:stem:InternalInternal plot construction or rendering fails unexpectedly.stem: internal operation failed
RunMat:plotting:TooManyOutputsMore than one output is requested from a coordinate chart constructor.plotting: too many output arguments

Behavior

stem(y) uses implicit x-values 1:n, while stem(x, y) uses explicit paired coordinates.

The returned value is a stem plot handle that works with get and set.

Baseline visibility, markers, fill behavior, display names, and line styling all flow through the shared plotting property model.

XData and YData retain the input numeric class, shape, and exact values, including wide int64 and uint64 data that cannot be represented exactly as double.

Figure-scene serialization preserves typed source data. Older scenes without typed source fields continue to load as ordinary double-backed plots.

The plot remains subplot-local and composes naturally with legends and axes-local state.

GPU-backed geometry is used when plotting-compatible buffers are available, with marker rendering sharing the point/marker pipeline.

Rendering and residency

stem has a dedicated GPU geometry path for supported floating buffers and shares the plotting marker pipeline. Integer source buffers use an exact owner-aware gather when direct export is unavailable; automatic residency remains transparent and integer bytes are never reinterpreted as floating geometry.

stem preserves GPU residency when the direct stem packer path is available. Marker rendering stays on the shared marker path.

Stem line geometry can be emitted directly from GPU buffers on the happy path.

Markers use the shared rendering path, which keeps style semantics aligned with the rest of the plotting stack.

Direct floating rendering precisions

single

double

Coordinate broadcasting

none

Runtime contract and boundaries

The result is a host graphics handle, not a numeric coordinate array. Coordinate parsing, native source storage, series expansion, style validation and graphics state use the existing plotting owners. Numeric handle aliases are resolved at Runtime, so static inference does not guess that a scalar coordinate denotes axes. The line, bar, barh and area constructors may return a row of handles; the other identities return the first created handle. More than one language output is rejected before chart work.

Single and double source data use their native storage where the chart has typed source properties; all eight integer classes use the declared identity-specific coordinate/control rules. Rendering is an explicit floating geometry boundary. In particular errorbar, bar, barh and area convert client graphics data to floating geometry; this does not certify exact integer-valued rendered pixels. Complex, logical, sparse, empty and matrix admission is decided by each existing numerical/shape parser, not by this shared ingress. Unsupported representations raise the existing parser diagnostic rather than being assumed fully MATLAB compatible.

Direct GPU rendering is conditional on the actual owning provider, live physical input leases, floating class/storage, supported shape/style, compatible shared device exports and native plotting feature availability. A pre-effect unavailable direct route may take the existing client path; a failed or partially completed export/reduction/emission is terminal and never permission to replay on the host. Source-property reads and figure persistence can perform later explicit readback. There is no elementwise/reduction fusion, distributed execution or portable numeric provider kernel for these graphics sinks.

User-interface capability and host-callback effects describe graphics creation/presentation, not numeric purity. Portable Runtime linking and an ordinary execution stack allow Native and Wasm ingress; actual presentation requires the installed graphics host. Retained chart data, style metadata, renderer buffers and serialization are separate lifetimes. Current chart scratch/state has no complete finite allocation owner: Managed policy is rejected before argument extraction, gather or chart mutation through the existing HostAllocationReceipt authority. Ordinary Unbounded resident and host routes remain available. Issuer/policy/cancellation are fenced before publication and errors carry Never replay. This refusal, unbounded host loops, provider/renderer-private allocations, full property parity and measured performance remain open obligations; Incomplete/Partial is not a completion certificate.

Supported representations and remaining forms

Coordinates use real single/double Tensor storage or native integer storage. Scalar logical coordinates pass through the existing NumericInput double conversion; logical arrays, complex arrays, sparse arrays, categorical and datetime coordinate objects do not have a NumericInput representation and are not implemented by this chart owner.

Y-only and X/Y forms, optional leading axes, LineSpec, filled, BaseValue, BaseLine, and shared name/value styling use the existing stem parser. Scalar Y now follows NumericInput; implicit X is 1:n with an empty index array when n is zero. StemPlot still rejects empty source coordinates, so empty-input MATLAB parity is incomplete. Host coordinate class/shape/value remains authoritative; baseline, line and marker fields cross the documented floating renderer boundary.

Examples

Create a stem plot from y-values only

stem([1 4 2 5 3]);

Use explicit x-values and filled markers

x = 0:5;
h = stem(x, [0 1 0 2 0 3]);
set(h, 'Filled', true, 'DisplayName', 'samples');
legend;

Inspect a stem handle after plotting

h = stem(1:5, [2 1 3 2 4]);
get(h, 'Type')

Expected output:

ans =
    'stem'

Discrete sampled signal

n = 0:31;
x = sin(2*pi*n/16) .* (0.9 .^ n);

stem(n, x);
title('Sampled Decaying Sinusoid');
xlabel('Sample index n');
ylabel('x[n]');
grid on;

Rendered stem example

n = 0:31;
x = sin(2*pi*n/16) .* (0.9 .^ n);

stem(n, x);
title('Sampled Decaying Sinusoid');
xlabel('Sample index n');
ylabel('x[n]');
grid on;
Expected output:
Decaying discrete sinusoid rendered as a MATLAB stem plot in RunMat

Compare this result with other chart types in the plot examples.

Using stem with coding agents

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

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

FAQ

When should I use stem instead of plot?⌄

stem is designed for discrete sequences where each sample is an independent value at a specific index—think impulse responses, sampled signals, or coefficient arrays. plot connects points with a continuous line, which implies interpolation between samples. If your data is inherently discrete and the gaps between samples matter, stem communicates that visually.

How do I customize the markers on a stem plot?⌄

Use the handle returned by stem with set to change marker shape, size, fill, and color.

h = stem(1:8, [3 1 4 1 5 9 2 6]);
set(h, 'Marker', 's', 'MarkerSize', 8, 'Filled', true, 'MarkerFaceColor', 'r');

Marker properties go through the same shared property model as plot and scatter, so the same property names work.

Can I change the baseline of a stem plot?⌄

Yes. Set the 'BaseValue' property on the stem handle to shift the baseline from the default of 0.

h = stem(1:5, [2 4 1 3 5]);
set(h, 'BaseValue', 2);

Stems will then extend from y=2 to each data point rather than from y=0.

Related Plotting functions

2D Charts

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

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 · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · drawnow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · gray · groot · hgload · hgsave · hidden · histogram2 · hold · hot · inferno · isgraphics · ishandle · jet · line · lines · linkaxes · magma · openfig · opengl · pan · parula · patch · pink · plasma · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · spring · stackedplot · subtitle · summer · suptitle · text · textscatter · textscatter3 · triplot · turbo · viridis · waitbar · winter · 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

Source you can read

Every RunMat function's source is public. Read exactly how stem is executed, line by line, in Rust.

  • View the source for stem in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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
  • Behavior
  • Rendering and residency
  • Direct floating rendering precisions
  • Coordinate broadcasting
  • Runtime contract and boundaries
  • Supported representations and remaining forms
  • Examples
  • Create a stem plot from y-values only
  • Use explicit x-values and filled markers
  • Inspect a stem handle after plotting
  • Discrete sampled signal
  • Rendered stem example
  • Using stem with coding agents
  • FAQ
  • Related Plotting functions
  • 2D Charts
  • 3D & Surface
  • Images
  • Axes & Layout
  • Appearance
  • Handle Access
  • Other
  • More plotting resources
  • Source you can read
  • About RunMat