Swarm scatter chart
swarmchart(
displays
a swarm chart, which is a scatter plot with the points offset (jittered) in the
x
,y
)x
-dimension. The points form distinct shapes, and the outline of each
shape is similar to a violin plot. Swarm charts help you to visualize discrete
x
data with the distribution of the y
data. At each
location in x
, the points are jittered based on the kernel density
estimate of y
.
swarmchart(
specifies the marker colors. To plot all the markers with the same color, specify
x
,y
,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 and y. Alternatively, you can specify a
three-column matrix of RGB triplets. The number of rows in the matrix must match the length
of x
and y
.
swarmchart(___,
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.
swarmchart(___,
fills in
the markers. Specify the 'filled'
)'filled'
option after all the arguments in any
of the previous syntaxes.
swarmchart(___,
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.
swarmchart(
displays the
swarm chart in the target axes. Specify the axes before all the arguments in any of the
previous syntaxes.ax
,___)
s = swarmchart(___)
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 y
and the relative number of points
at each x
location. This behavior corresponds to the default
'density'
setting of the XJitter
property on the
Scatter
object when you call the swarmchart
function.
The maximum spread of points at each x
location is 90% of the smallest distance between adjacent x
values by
default:
spread = 0.9 * min(diff(unique(x)));
You can control the spread by setting the XJitterWidth
property on
the Scatter
object.