swarmchart3

Draws a 3-D scatter plot whose points are spread sideways to avoid overlap.

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

Syntax

swarmchart3(x, y, z)

Draws points at (x, y, z), spread in the xy-plane according to density.

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

Sets marker size and colors.

h = swarmchart3(___)

Also returns the chart object.

Description

This is the 3-D version of swarmchart. The z values are the quantity being compared, and points that share an (x, y) position are shifted in the horizontal plane according to the local density of z.

Input arguments

x, y
Group positions in the plane.
z
Values to display.

Output arguments

h
Handle of the chart.

Example

Two groups in 3-D

rng(1);
x = [ones(1, 20), 2*ones(1, 20)];
y = ones(1, 40);
z = randn(1, 40);
swarmchart3(x, y, z)

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

See also

swarmchart scatter3 plot3