Navigation

Operators and Keywords

Function List:

C++ API

: scatter3 (x, y, z)
: scatter3 (x, y, z, s)
: scatter3 (x, y, z, s, c)
: scatter3 (…, style)
: scatter3 (…, "filled")
: scatter3 (…, prop, val)
: scatter3 (hax, …)
: h = scatter3 (…)

Draw a 3-D scatter plot.

A marker is plotted at each point defined by the coordinates in the vectors x, y, and z.

The size of the markers is determined by s, which can be a scalar or a vector of the same length as x, y, and z. If s is not given, or is an empty matrix, then a default value of 8 points is used.

The color of the markers is determined by c, which can be a string defining a fixed color; a 3-element vector giving the red, green, and blue components of the color; a vector of the same length as x that gives a scaled index into the current colormap; or an Nx3 matrix defining the RGB color of each marker individually.

The marker to use can be changed with the style argument, that is a string defining a marker in the same manner as the plot command. If no marker is specified it defaults to "o" or circles. If the argument "filled" is given then the markers are filled.

Additional property/value pairs are passed directly to the underlying patch object.

If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

The optional return value h is a graphics handle to the hggroup object representing the points.

[x, y, z] = peaks (20);
scatter3 (x(:), y(:), z(:), [], z(:));

See also: scatter, patch, plot.

Demonstration 1

The following code

 clf;
 [x, y, z] = peaks (20);
 scatter3 (x(:), y(:), z(:), [], z(:));
 title ({"Default scatter3() plot", ...
         "constant size bubbles and color determined by Z"});

Produces the following figure

Figure 1

Demonstration 2

The following code

 clf;
 x = rand (20,1);  y = rand (20,1);  z = rand (20,1);
 scatter3 (x(:), y(:), z(:), 10, z(:), "s");
 title ({"scatter3() plot", ...
         "marker is square, size is 10, color determined by Z"});

Produces the following figure

Figure 1

Demonstration 3

The following code

 clf;
 x = rand (20,1);  y = rand (20,1);  z = rand (20,1);
 scatter3 (x(:), y(:), z(:), 20*z(:), [], "s");
 title ({"scatter3() plot", ...
         "marker is square, size is determined by Z"});

Produces the following figure

Figure 1

Demonstration 4

The following code

 clf;
 x = rand (20,1);  y = rand (20,1);  z = rand (20,1);
 scatter3 (x(:), y(:), z(:), 20*z(:), z(:), "s");
 title ({"scatter3() plot", ...
         "marker is square, size and color determined by Z"});

Produces the following figure

Figure 1

Package: octave