%% Parallel Coordinates Plot with Binned Data
% Create a parallel coordinates plot from a matrix containing medical patient data. Bin the values in one of the columns in the matrix, and group the lines in the plot using the binned values.
% Load the patients data set, and create a matrix from the Age, Height, and Weight values. Create a parallel coordinates plot using the matrix data. Label the coordinate variables in the plot. The lines in the plot correspond to individual patients.

load patients
X = [Age Height Weight];
p = parallelplot(X)
p.CoordinateTickLabels = {'Age (years)','Height (inches)','Weight (pounds)'};

%
% Create a new categorical variable that groups each patient into one of three categories: short, average, or tall. Set the bin edges such that they include the minimum and maximum Height values.

min(Height)
max(Height)
binEdges = [60 64 68 72];
bins = {'short','average','tall'};
groupHeight = discretize(Height,binEdges,'categorical',bins);

%
% Now use the groupHeight values to group the lines in the parallel coordinates plot. The plot indicates that short patients tend to weigh less than tall patients.

p.GroupData = groupHeight;

% Copyright 2018 The MathWorks, Inc.