scatter3

3-D scatter plot: markers at given 3-D positions, with optional size and color.

Category: Graphics > 2-D and 3-D Plots

Syntax

scatter3(x, y, z)

Draws a circle at each point (x(k), y(k), z(k)).

scatter3(x, y, z, sz)

Sets the marker area.

scatter3(x, y, z, sz, c)

Sets the color of the markers.

scatter3(___, 'filled')

Fills the markers.

s = scatter3(___)

Also returns the Scatter object.

Description

It extends scatter to three coordinates. Rotating the view, with the mouse or view, is usually needed to read the depth. Color by one more variable to show a fourth quantity.

Input arguments

x, y, z
Vectors of the same length.
sz
Marker area in points squared.
c
Color spec, RGB triplet, or values mapped through the colormap.

Output arguments

s
Scatter object with XData, YData and ZData.

Example

Random cloud colored by height

rng(1)
x = randn(100, 1);
y = randn(100, 1);
z = x.*y;
scatter3(x, y, z, 25, z)
colorbar

In the app, the figure is drawn below the code.

See also

scatter plot3 bubblechart3 view