scatterplot — Plot complex-valued samples as 2-D constellation points with MATLAB-compatible scatterplot workflows.
scatterplot visualizes complex samples by plotting real(x) on the x-axis and imag(x) on the y-axis. It supports MATLAB-compatible forms for decimation, offset, marker styling, and target axes selection.
Syntax
h = scatterplot(x)
h = scatterplot(x, n)
h = scatterplot(x, n, offset)
h = scatterplot(x, n, offset, marker)
h = scatterplot(x, n, offset, marker, ax)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
x | NumericArray | Yes | — | Complex-baseband samples. Real inputs are plotted with zero imaginary part. |
x | NumericArray | Yes | — | Complex-baseband samples. |
n | IntegerScalar | Yes | — | Positive decimation factor; every n-th sample is plotted. |
offset | IntegerScalar | Yes | — | Zero-based sample offset before decimation. |
n | IntegerScalar | Yes | — | Positive decimation factor. |
marker | StyleSpec | Yes | — | Marker LineSpec forwarded to scatter. |
ax | AxesHandle | Yes | — | Target axes handle. |
Returns
| Name | Type | Description |
|---|---|---|
h | NumericScalar | Figure/graphics handle returned by the underlying scatter plot. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:scatterplot:InvalidArgument | The input samples, decimation factor, offset, marker, or axes handle is invalid. | scatterplot: invalid argument |
RunMat:scatterplot:PlotFailed | The underlying scatter plot cannot be rendered. | scatterplot: plot operation failed |
How scatterplot works
scatterplot(x)plots every complex sample using a constellation-friendly default marker.scatterplot(x, n)plots everyn-th sample.scatterplot(x, n, offset)starts at the zero-based offset before applying decimation, matching MATLAB'sx(offset+1:n:end)behavior.scatterplot(x, n, offset, marker)forwards the marker LineSpec toscatter.scatterplot(x, n, offset, marker, ax)targets an existing axes handle.- The generated plot uses equal x/y scaling and grid lines so constellation geometry is not visually distorted.
Does RunMat run scatterplot on the GPU?
The direct path reuses the existing 2-D scatter WGPU renderer and avoids an extra host round-trip for supported GPU inputs.
Decimated sample selection is currently performed on the host to preserve MATLAB-compatible offset semantics.
Marker styling, axes targeting, grid, and equal-axis behavior are consistent between GPU and host fallback rendering.
GPU memory and residency
scatterplot preserves GPU residency for the common scatterplot(x) path when the active provider can materialize real and imaginary buffers on device. Decimation and provider gaps fall back to one host gather, after which the same scatter handle and axes behavior apply.
Examples
Plot a simple QPSK constellation
x = [1+1i; -1+1i; -1-1i; 1-1i];
scatterplot(x);Plot every fourth received sample with a custom marker
rx = randn(1000, 1) + 1i*randn(1000, 1);
scatterplot(rx, 4, 0, 'gx');Target a subplot axes
ax = subplot(1, 2, 1);
x = [1+1i; 1-1i; -1+1i; -1-1i];
scatterplot(x, 1, 0, 'b.', ax);Using scatterplot with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how scatterplot changes the result.
Run a small scatterplot example, explain the result, then change one input and compare the output.
FAQ
How is scatterplot different from scatter?⌄
scatterplot is specialized for complex symbols. It derives x/y coordinates from the real and imaginary parts of one input vector, applies Communications Toolbox decimation/offset arguments, and configures the axes for constellation viewing. scatter expects explicit x and y coordinate arrays.
Does scatterplot support gpuArray inputs?⌄
Yes. For the no-decimation case, RunMat asks the acceleration provider for real and imaginary GPU buffers and forwards them to the GPU scatter renderer. When decimation is requested or the provider cannot expose those buffers, RunMat gathers the samples once and renders the same visible plot.
Related guides
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how scatterplot is executed, line by line, in Rust.
- View the source for scatterplot 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.