RunMat
GitHub

All functions

CategoryPlotting
Auto GPU

RunMat automatically offloads this function to the GPU when it estimates a speedup, without requiring explicit gpuArray inputs.

Learn more about Auto GPU →

scatter3 — Create 3-D scatter plots for spatial point clouds, encoded markers, and MATLAB scatter3 workflows.

scatter3 creates 3-D marker plots from matching x, y, and z coordinates. In RunMat it participates in the handle-returning plotting system, which means you can combine it with subplot, inspect the figure with get, adjust camera angles with view, and keep GPU-resident inputs on device when the shared rendering path is available.

How scatter3 works

  • scatter3(x, y, z) requires matching element counts across all three inputs.
  • The builtin returns a scatter handle for the created plot object.
  • 3-D scatter plots work naturally with view and zlabel, and all camera state remains subplot-local.
  • GPU-resident coordinate buffers can feed the renderer directly on the happy path; otherwise RunMat gathers once before plotting.
  • Marker size and display-name style workflows are handled through the shared plotting object/property system.

How RunMat runs scatter3 on the GPU

The preferred path keeps point buffers on the device and emits renderer-ready geometry without a full host round-trip.

Subplot, view, and object-handle behavior is the same on both the GPU and fallback host paths.

GPU memory and residency

scatter3 preserves GPU residency when the plotting path can consume exported coordinate buffers directly. If a direct GPU path is not available for the active combination, RunMat gathers once and renders the same plot semantics on the host path.

Examples

Plot a 3-D helix as a point cloud

t = linspace(0, 6*pi, 300);
scatter3(cos(t), sin(t), t);

Style a 3-D scatter plot and change the camera view

t = linspace(0, 4*pi, 200);
h = scatter3(cos(t), sin(t), t);
set(h, 'DisplayName', 'helix', 'SizeData', 10);
view(45, 25);

Use subplot-local camera state with multiple 3-D plots

subplot(1, 2, 1);
scatter3(1:10, rand(1,10), rand(1,10));
view(3);
subplot(1, 2, 2);
scatter3(rand(1,10), rand(1,10), rand(1,10));
view(2);

Expected output:

% The two subplots keep independent 3-D view state

3D point cloud with color-coded altitude

n = 2000;
theta = 4*pi*rand(1, n);
r = sqrt(rand(1, n));
x = r .* cos(theta);
y = r .* sin(theta);
z = sin(3*r) ./ (1 + r);

scatter3(x, y, z, 12, z, 'filled');
colormap('turbo');
colorbar;
title('3-D Point Cloud — Altitude Encoded');
xlabel('x');
ylabel('y');
zlabel('z');
view(35, 25);
grid on;
Expected output:
3D point cloud with color-coded altitude

FAQ

How do I size scatter3 points by a data variable?

Pass a size vector as the fourth argument. Each element controls the marker area for the corresponding point.

t = linspace(0, 4*pi, 200);
sizes = linspace(5, 50, 200);
scatter3(cos(t), sin(t), t, sizes);

A scalar fourth argument sets all points to the same size.

Can I color scatter3 points by a fourth variable?

Pass a color vector as the fifth argument after the size vector. Each value maps through the active colormap. Add colorbar to show the mapping.

scatter3(x, y, z, 20, myValues);
colormap('turbo');
colorbar;
How do I rotate or orbit a scatter3 plot?

Use view(az, el) to set the camera angle programmatically. az is the horizontal orbit in degrees, el is the vertical tilt. view(3) gives the standard 3-D default. Each subplot keeps its own independent camera state, so you can show the same data from multiple angles in a subplot grid.

2D Charts

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

3D & Surface

contour · contourf · mesh · meshc · plot3 · quiver · 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

cla · clf · figure · fill3 · hold · patch · suptitle · xline · yline

More plotting resources

Open-source implementation

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

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat for free

Write code or describe what you want to compute. The sandbox is free, no account required.