3-D swarm scatter chart
swarmchart3(
displays a 3-D swarm chart, which is a scatter plot with the points offset (jittered) in the
x
,y
,z
)x
- and y
-dimensions. The points form distinct
shapes, and the outline of each shape is similar to a violin plot. 3-D swarm charts help you
to visualize discrete (x
,y
) data with the distribution
of the z data. At each (x
,y
)
location, the points are jittered based on the kernel density estimate of
z
.
swarmchart3(
specifies the marker colors. To plot all the markers with the same color, specify
x
,y
,z
,sz
,c
)c
as a color name or an RGB triplet. To assign a different color to
each marker, specify a vector the same size as x
, y
,
and z
. Alternatively, you can specify a three-column matrix of RGB
triplets. The number of rows in the matrix must match the length of x
,
y
, and z
.
swarmchart3(___,
specifies a
different marker than the default marker, which is a circle. Specify mkr
)mkr
after all the arguments in any of the previous syntaxes.
swarmchart3(___,
fills in
the markers. Specify the 'filled'
)'filled'
option after all the arguments in any
of the previous syntaxes.
swarmchart3(___,
specifies additional properties for the swarm chart using one or more
Name,Value
)Name,Value
pair arguments. Specify the properties after all other input
arguments. For a list of properties, see Scatter Properties.
swarmchart3(
displays the
swarm chart in the target axes. Specify the axes before all the arguments in any of the
previous syntaxes.ax
,___)
s = swarmchart3(___)
returns the
Scatter
object. Use s
to modify properties of the
chart after creating it. For a list of properties, see Scatter Properties.
The points in a swarm chart are jittered using uniform random values that are weighted by
the Gaussian kernel density estimate of z
and the relative number of points
at each (x
, y
) location. This behavior corresponds to
the default 'density'
setting of the XJitter
and
YJitter
properties on the Scatter
object when you call
the swarmchart3
function.
The maximum spread of points at each x
location is 90% of the smallest distance between adjacent points by default. For example, in
the x
dimension, the spread is calculated
as:
spread = 0.9 * min(diff(unique(x)));
You can control the offset by setting the XJitterWidth
and
YJitterWidth
properties on the Scatter
object.