%% Plot Data from a Table
% A convenient way to plot data from a table is to pass the table to the swarm3 function and specify the variables you want to plot. For example, create a table with four variables of random numbers, and plot the X, Y1, and Z variables. By default, the axis labels match the variable names.

tbl = table(randi(2,100,1),randi(2,100,1),randi([10 11],100,1), ...
   randn(100,1),'VariableNames',{'X','Y1','Y2','Z'});

swarmchart3(tbl,'X','Y1','Z')

%
% You can also plot multiple variables at the same time. For example, plot Y1 and Y2 on the y-axis by specifying the yvar argument as the cell array {'Y1','Y2'}. Then add a legend. The legend labels match the variable names.

swarmchart3(tbl,'X',{'Y1','Y2'},'Z')
legend

% Copyright 2020 The MathWorks, Inc.